Newer
Older
HuangJiPC / src / pages / views / performance / evaluationLS.vue
@zhangdeliang zhangdeliang on 21 Jun 50 KB update
<template>
  <!-- 临时考核 -->
  <div class="LinshiPage">
    <div class="searchBoxs">
      <n-space>
        <n-space>
          <n-date-picker v-model:value="searchTim1" type="month" placeholder="考核月份" />
        </n-space>
        <n-select v-model:value="searchVal1" style="width: 200px" placeholder="考核类型" :options="bkwzOptions" clearable> </n-select>
        <n-button type="primary" @click="handleClick('search')">
          <template #icon>
            <n-icon><Search /> </n-icon>
          </template>
          搜索
        </n-button>
        <n-button type="primary" @click="handleClick('add')">
          <template #icon>
            <n-icon><Add /> </n-icon>
          </template>
          新增
        </n-button>
      </n-space>
    </div>
    <!-- 表格 -->
    <div class="tableBox">
      <n-data-table
        :bordered="false"
        :max-height="700"
        striped
        :columns="columns"
        :data="tableData"
        :loading="tableLoading"
        :remote="true"
        :pagination="pagination"
      >
      </n-data-table>
    </div>
    <!-- 考评弹窗 -->
    <n-modal
      :title="kaopingTitle"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '1800px' }"
      v-model:show="kaopingShow"
    >
      <div class="kaopingTable">
        <n-radio-group v-model:value="kaopingtypeValue.Type">
          <n-space>
            <!-- 项目产出绩效考核指标  项目运营维护绩效考核指标 成本效益和安全保障绩效考核指标-->
            <n-radio :value="item.id" v-for="item in radioArr" :key="item.id" @change="changeRadio">
              {{ item.name }}
            </n-radio>
          </n-space>
        </n-radio-group>
        <n-divider />
        <n-data-table
          :bordered="true"
          :max-height="700"
          :single-line="false"
          :columns="kaopingcolumns"
          :data="kaopingtableData"
          :loading="tableLoadingKP"
          :remote="true"
        >
        </n-data-table>
      </div>
    </n-modal>
    <!-- 考评发现问题点击弹窗 -->
    <n-modal
      :title="issuesTitle"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '1800px' }"
      v-model:show="findissues"
    >
      <n-form label-align="right" require-mark-placement="left" :label-width="100" label-placement="left">
        <n-form-item>
          <n-input v-model:value="scoreStandard" type="textarea" readonly="true" autosize></n-input>
        </n-form-item>
        <n-form-item>
          <n-button type="primary" @click="handleClick('addissues')">新增临时考核问题</n-button>
        </n-form-item>
        <n-form-item>
          <n-data-table
            :bordered="true"
            :single-line="false"
            :max-height="400"
            :striped="true"
            :columns="findissuescolumns"
            :data="findissuesData"
            :pagination="pagination2"
            :loading="tableListLoading"
            :remote="true"
          >
          </n-data-table>
        </n-form-item>
      </n-form>
    </n-modal>
    <!-- 考评发现问题新增弹窗 -->
    <n-modal
      title="临时考核添加问题详情"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '1700px' }"
      v-model:show="addissueShow"
    >
      <Kpques
        :indexId="addFormValue.data.indexId"
        :codeId="addFormValue.data.codeId"
        :mainId="addFormValue.data.mainId"
        :relIndexIdType="addFormValue.data.relIndexIdType"
        :type="addFormValue.data.type"
        :indexscore="addFormValue.data.indexscore"
        :ifQuesUpdate="ifQuesUpdate"
        :updateQuesObj="updateQuesObj"
        @refreshData="refreshData"
      ></Kpques>
    </n-modal>

    <!-- 考评发现问题详情弹窗 -->
    <n-modal
      title="问题详情查看"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '600px' }"
      v-model:show="addissueDetailShow"
    >
      <KpquesDetail :quesDetailId="quesDetailId"></KpquesDetail>
    </n-modal>
    <!-- 子项信息 -->
    <n-modal
      :title="projectTitle"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '1000px' }"
      v-model:show="projectShow"
    >
      <n-form label-align="right" :label-width="80" label-placement="left" inline> </n-form>
      <n-data-table
        :bordered="true"
        :single-line="false"
        :max-height="700"
        :striped="true"
        :columns="projectSubcolumns"
        :data="projectData"
        :loading="SubProjectLoading"
        :remote="true"
      >
      </n-data-table>
    </n-modal>

    <!-- 问题清单 -->
    <n-modal
      title="临时考核问题清单"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '1800px' }"
      v-model:show="deductShow"
    >
      <n-form label-align="right" require-mark-placement="left" :label-width="80" label-placement="left" inline>
        <n-form-item label="临时考核状态:" path="status">
          <n-select v-model:value="problemStatus" style="width: 100px" :options="deductstateOptions" clearable> </n-select>
        </n-form-item>
        <n-form-item label="项目类型:" path="codeName">
          <n-select
            v-model:value="problemcodeId"
            style="width: 300px"
            :options="deductypeOptions"
            default-value="40"
            clearable
            @update:value="changeSelect1"
          >
          </n-select>
        </n-form-item>
        <n-form-item label="考核项目:" path="degist">
          <n-select
            v-model:value="problemsubProjectId"
            style="width: 300px"
            :options="subProjectOptions"
            default-value="80"
            clearable
            @update:value="changeSelect2"
          >
          </n-select>
        </n-form-item>
        <n-form-item label="指标类型:" path="degist">
          <n-select v-model:value="indexOneId" style="width: 200px" :options="indexOneOptions" clearable @update:value="changeSelect3">
          </n-select>
        </n-form-item>
        <n-form-item>
          <n-button type="primary" @click="handleClick('searchproblem')">查询</n-button>
          <n-button type="primary" style="margin-left: 10px" @click="exportQues">导出</n-button>
        </n-form-item>
      </n-form>
      <n-data-table
        :bordered="true"
        :single-line="false"
        :max-height="600"
        :striped="true"
        :columns="Listcolumns"
        :data="tableListData"
        :loading="tableLoadingQD"
        :remote="true"
        :pagination="pagination3"
      >
      </n-data-table>
    </n-modal>
    <!-- 整改弹窗 -->
    <n-modal
      :title="RectifyTitle"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '600px' }"
      v-model:show="RectifyShow"
    >
      <n-form
        ref="RectifyformRef"
        label-align="right"
        :label-width="150"
        require-mark-placement="left"
        :rules="RectifyformInfo.rules"
        :model="RectifyformInfo.data"
        label-placement="left"
      >
        <n-form-item label="整改人员:" path="dealMan">
          <n-select v-model:value="RectifyformInfo.data.dealMan" :options="userOptions" filterable> </n-select>
        </n-form-item>
        <n-form-item label="整改时间:" path="dealTime">
          <n-date-picker v-model:value="RectifyformInfo.data.dealTime" type="datetime" placeholder="请选择" style="width: 100%" />
        </n-form-item>
        <n-form-item label="处理结果:" path="dealResult">
          <n-input
            v-model:value="RectifyformInfo.data.dealResult"
            type="textarea"
            maxlength="200"
            show-count
            :autosize="{ minRows: 5, maxRows: 10 }"
          />
        </n-form-item>
        <n-form-item label="整改图片:" path="fileNo" class="uploadWarns">
          <n-upload
            v-model:file-list="uploadListZG"
            accept=".jpg,.png,.jpeg,.svg,.gif"
            :max="3"
            list-type="image-card"
            @change="changeFileZG"
          >
          </n-upload>
          <span style="margin-top: 10px">提示:格式为.jpg,.png,.jpeg,.svg,.gif,每个图片大小小于10M</span>
        </n-form-item>
        <n-form-item>
          <n-button type="primary" style="left: 90%" @click="handleClick('rectifySave')">提交</n-button>
        </n-form-item>
      </n-form>
    </n-modal>
    <!-- 核销弹窗 -->
    <n-modal :title="HXTitle" :mask-closable="false" preset="dialog" :show-icon="false" :style="{ width: '600px' }" v-model:show="HXShow">
      <n-form
        ref="HXformRef"
        label-align="right"
        :label-width="80"
        require-mark-placement="left"
        :rules="HXformInfo.rules"
        :model="HXformInfo.data"
        label-placement="left"
      >
        <n-form-item label="核销人员:" path="checkMan">
          <n-select v-model:value="HXformInfo.data.checkMan" :options="userOptions" filterable> </n-select>
        </n-form-item>
        <n-form-item label="核销时间:" path="checkTime">
          <n-date-picker v-model:value="HXformInfo.data.checkTime" type="datetime" placeholder="请选择" style="width: 100%" />
        </n-form-item>
        <n-form-item style="margin-top: 300px">
          <n-button type="primary" style="left: 90%" @click="handleClick('hexiao')">提交</n-button>
        </n-form-item>
      </n-form>
    </n-modal>
    <!-- 新增修改临时考核弹窗 -->
    <n-modal
      :title="modalTitle"
      :mask-closable="false"
      preset="dialog"
      :show-icon="false"
      :style="{ width: '550px' }"
      v-model:show="modalShow"
    >
      <n-form
        ref="formRef"
        label-align="right"
        require-mark-placement="left"
        :label-width="120"
        :rules="formInfo.rules"
        :model="formInfo.data"
        label-placement="left"
        style="height: 270px"
      >
        <n-form-item label="考核类型:" path="performType">
          <n-select v-model:value="formInfo.data.performType" :options="bkwzOptions" clearable> </n-select>
        </n-form-item>
        <n-form-item label="考核时间:" path="yearMonth">
          <n-date-picker style="width: 100%" v-model:value="formInfo.data.yearMonth" type="month" />
        </n-form-item>
        <n-form-item label="抽查工程子项:" path="projectSubArray" style="color: red; font-size: 0.5em">
          <n-select
            v-model:value="formInfo.data.projectSubArray"
            :options="examineOptions"
            placeholder="请选择抽查工程子项(可多选):"
            multiple
            clearable
          >
          </n-select>
        </n-form-item>
        <n-form-item label="抽查考核范围:" path="performArray" style="color: red; font-size: 0.5em">
          <n-select
            v-model:value="formInfo.data.performArray"
            :options="rangeOptions"
            placeholder="请选择抽查考核范围(可多选):"
            multiple
            clearable
          >
          </n-select>
        </n-form-item>
      </n-form>
      <n-divider />
      <template #action>
        <n-space>
          <n-button type="primary" @click="handleClick('submit')">保存</n-button>
          <n-button @click="() => (modalShow = false)">取消</n-button>
        </n-space>
      </template>
    </n-modal>
  </div>
</template>

<script>
import { toRefs, onMounted, reactive, h, ref, nextTick } from 'vue';
import { Search, Add } from '@vicons/ionicons5';
import { NButton, NTag, NInput, NImage } from 'naive-ui';
import Kpques from './evaluationQues.vue'; //指标问题添加
import KpquesDetail from './evaluationQuesDetail.vue'; //指标问题详情查看
import { downloadBlob } from '@/utils/util';
import {
  fileUpload,
  fileDelete,
  AssessSelectInfo,
  IndexsClassOne,
  AssessLSResultSave,
  AssessResultUpdate,
  AssessLSResultInfo,
  LSproblemList,
  LSKaopingGetData,
  RadioKaopingGetData,
  AssessResultDel,
  KaopingGetProblemData,
  addProblemSave,
  AssessRectification,
  AssessCheckQuestions,
  SelectSubProject,
  getAllProjectType,
  getSubProjectTypeByCodeId,
  getIndexsOneListBySubProjectId,
  AssessCheckDelete,
  allUserGet,
} from '@/services';
import { resetForm, formatDate } from '@/utils/util';
import axios from 'axios';

export default {
  name: 'weihuPage',
  components: { Search, Add, NButton, Kpques, KpquesDetail },
  setup() {
    const allData = reactive({
      userOptions: [],
      searchVal1: null,
      searchTim1: null,
      searchVal2: null,
      searchVal3: null,
      ifQuesUpdate: false,
      updateQuesObj: {},
      projectTitle: '抽查子项信息',
      auditName: '',
      SubProjectLoading: true,
      projectShow: false,
      projectData: [],
      scoreStandard: '', //评分标准
      problemStatus: null, //扣分问题数问题状态
      problemcodeId: null, //扣分问题数项目类型
      problemsubProjectId: null, //扣分问题数考核项目
      indexOneId: null, //扣分问题数指标类型
      mainId: null,
      oneLevelId: null,
      radioArr: [],
      quesDetailId: null, //查看指标问题详情id
      modalTitle: '新增临时考核',
      kaopingTitle: '', //考评弹窗
      RectifyTitle: null, //整改弹窗
      checkTitle: null, //查看弹窗
      HXTitle: '', //核销弹窗
      HXId: '',
      HXShow: false,
      issuesTitle: null, //去考评发现问题查看
      modalShow: false,
      kaopingShow: false,
      findissues: false,
      deductShow: false,
      RectifyShow: false,
      addissueShow: false,
      addissueDetailShow: false,
      issuesShow: false,
      uploadList: [],
      uploadListXC: [],
      uploadListZG: [], //整改现场图片
      imageXC: [],
      imageZG: [], //整改现场图片
      rectifyid: null, //整改所需ID
      addFormValue: {
        data: {
          questDesc: null,
          fileNo: [],
          subProjectId: null,
          mainId: null,
          indexId: null,
          codeId: null,
          cutScore: null,
          type: 0,
          indexscore: null,
          relIndexIdType: null,
        },
        rules: {
          questDesc: {
            required: true,
            trigger: ['blur'],
            message: '请输入问题描述',
          },
          subProjectId: {
            type: 'number',
            required: true,
            trigger: ['change'],
            message: '请选择考核子项',
          },
          cutScore: {
            type: 'number',
            required: true,
            trigger: ['change'],
            message: '请输入',
          },
        },
      },
      kaopingtypeValue: {
        Type: 0,
      },
      formInfo: {
        data: {
          projectSubArray: null, //抽查工程子项
          performArray: null, //抽查考核范围
          //performName: null, //考核名称
          performType: null, //考核类型
          yearMonth: null, //考核时间
          year: null, //考核年
          questions: null, //考核问题数
          degist: '',
          fileNo: [],
          content: '',
          createTime: null,
        },
        rules: {
          yearMonth: {
            type: 'number',
            required: true,
            trigger: ['change', 'blur'],
            message: '请选择考核时间',
          },
          // performName: {
          //   required: true,
          //   trigger: ['blur'],
          //   message: '请输入考核名称',
          // },
          performType: {
            type: 'number',
            required: true,
            trigger: ['change'],
            message: '请选择',
          },
          projectSubArray: {
            type: 'array',
            required: true,
            trigger: ['change'],
            message: '请选择',
          },
          performArray: {
            type: 'array',
            required: true,
            trigger: ['change'],
            message: '请选择',
          },
        },
      },
      //问题清单
      problemlist: {
        data: {
          status: null, //问题状态
          codeName: null, //项目类型
          insOneId: null, //一级指标
          insTwoId: null, //二级指标
          projectSub: null, //考核项目
        },
      },
      //去考评发现问题查看信息
      issuesformInfo: {
        data: {
          mainName: null,
          questDesc: null,
          reportMan: null,
        },
      },
      RectifyformInfo: {
        data: {
          dealResult: null,
          dealTime: null,
          dealMan: null,
          fileNo: [],
          id: null,
        },
        rules: {
          dealMan: { required: true, trigger: ['change'], message: '请选择' },
          dealTime: { required: true, trigger: ['change'], message: '请选择', type: 'number' },
          dealResult: { required: true, trigger: ['blur'], message: '请输入处理结果' },
        },
      },
      HXformInfo: {
        data: {
          checkMan: null,
          checkTime: null,
          id: null,
        },
        rules: {
          checkMan: { required: true, trigger: ['change'], message: '请选择' },
          checkTime: { required: true, trigger: ['change'], message: '请选择', type: 'number' },
        },
      },
      checkformInfo: {
        data: {
          checkinfo: null,
        },
      },
      tableLoading: true,
      tableLoadingKP: true,
      tableListLoading: true,
      tableLoadingQD: true,
      tableData: [],
      tableListData: [],
      findissuesData: [],
      kaopingtableData: [],
      addissuesData: [],
      bkwzOptions: [
        { value: 1, label: '水务局考核' },
        { value: 0, label: '项目公司考核' },
      ],
      examineOptions: [],
      rangeOptions: [],
      deductstateOptions: [
        { value: 0, label: '待整改' },
        { value: 1, label: '已整改' },
        { value: 2, label: '已核销' },
      ],
      deductypeOptions: [],
      subProjectOptions: [],
      indexOneOptions: [],
      columns: [
        {
          title: '序号',
          align: 'center',
          width: '80',
          render(row, index) {
            return (paginationReactive.page - 1) * paginationReactive.pageSize + index + 1;
          },
        },
        {
          title: '考核名称',
          align: 'center',
          key: 'performName',
        },
        { title: '考核类型', align: 'center', key: 'performType' },
        { title: '考核时间', align: 'center', key: 'evaluateTime', width: '160' },
        {
          title: '抽查子项个数',
          align: 'center',
          key: 'projectSubCount',
          render(row) {
            return h(
              NTag,
              {
                bordered: true,
                type: 'success',
                onClick: () => handleClick('projectSubCount', row),
              },
              { default: () => row.projectSubCount }
            );
          },
        },
        {
          title: '扣分问题数',
          align: 'center',
          key: 'questions',
          render(row) {
            return h(
              NTag,
              {
                bordered: true,
                type: 'error',
                onClick: () => handleClick('deductNum', row),
              },
              { default: () => row.questions }
            );
          },
        },
        { title: '创建人', align: 'center', key: 'createUser' },
        { title: '创建时间', align: 'center', key: 'createTime', width: '160' },
        {
          title: '操作',
          key: 'actions',
          width: '240',
          align: 'center',
          render(row) {
            const btn = allData.actionColumn.map((item, index) => {
              return h(
                NButton,
                {
                  text: true,
                  size: item.size,
                  style: {
                    margin: '10px',
                  },
                  type: item.btnType,
                  onClick: () => handleClick(item.type, row),
                },
                { default: () => item.default }
              );
            });
            return btn;
          },
        },
      ],
      kaopingcolumns: [
        {
          title: '考核项目',
          align: 'center',
          key: 'codeName',
          rowSpan: (row, index) => {
            return row.rowSpan0;
          },
          width: '120',
        },
        {
          title: '一级指标',
          align: 'center',
          key: 'insOneName',
          rowSpan: (row, index) => {
            return row.rowSpan1;
          },
          width: '120',
        },
        {
          title: '二级指标',
          align: 'center',
          key: 'insTwoName',
          rowSpan: (row, index) => {
            return row.rowSpan2;
          },
          width: '120',
        },
        {
          title: '三级指标',
          align: 'center',
          key: 'insThreeName',
          rowSpan: (row, index) => {
            return row.rowSpan3;
          },
          width: '120',
        },
        { title: '指标名称', align: 'center', key: 'indexName' },
        { title: '指标解释', align: 'center', key: 'indexExp', ellipsis: { tooltip: true } },
        { title: '评价依据', align: 'center', key: 'scoreBasis', ellipsis: { tooltip: true } },
        { title: '评分标准', align: 'center', key: 'scoreStandard', ellipsis: { tooltip: true } },
        { title: '标准分值', align: 'center', key: 'score', width: '60' },
        { title: '实际得分', align: 'center', key: 'acuScore', width: '60' },
        {
          title: '发现问题',
          align: 'center',
          key: 'questions',
          width: '60',
          render(row) {
            return h(
              NTag,
              {
                type: 'success',
                onClick: () => handleClick('findissues', row),
              },
              { default: () => row.questions }
            );
          },
        },
      ],
      Listcolumns: [
        {
          title: '序号',
          align: 'center',
          width: '60',
          render(row, index) {
            return (paginationReactive.page - 1) * paginationReactive.pageSize + index + 1;
          },
        },
        { title: '考核子项目', align: 'center', key: 'subProjectName', width: '160' },
        { title: '考核指标', align: 'center', key: 'indexName', width: '160' },
        { title: '问题原因', align: 'center', key: 'questTypeName' },
        {
          title: '问题描述',
          align: 'center',
          key: 'questDesc',
          ellipsis: {
            tooltip: true,
          },
        },
        { title: '状态', align: 'center', key: 'statusDesc', width: '80' },
        { title: '扣分', align: 'center', key: 'cutScore', width: '60' },
        { title: '上报人', align: 'center', key: 'reportMan', width: '80' },
        { title: '上报时间', align: 'center', key: 'reportTime', width: '160' },
        { title: '整改人', align: 'center', key: 'dealMan', width: '80' },
        { title: '整改时间', align: 'center', key: 'dealTime', width: '160' },
        { title: '核销人', align: 'center', key: 'checkMan', width: '80' },
        { title: '核销时间', align: 'center', key: 'checkTime', width: '160' },
        {
          title: '操作',
          key: 'operation',
          width: '220',
          align: 'center',
          render(row) {
            let arrs = [];
            if (row.status == 0) {
              arrs = [
                { btnType: 'success', type: 'rectify', default: '整改' },
                { btnType: 'primary', type: 'editQuesqd', default: '修改' },
                { btnType: 'info', type: 'qdInfo', default: '查看' },
              ];
            } else if (row.status == 1) {
              arrs = [
                { btnType: 'info', type: 'qdInfo', default: '查看' },
                { btnType: 'primary', type: 'editQuesqd', default: '修改' },
                { btnType: 'default', type: 'logout', default: '核销' },
              ];
            } else {
              arrs = [
                { btnType: 'primary', type: 'editQuesqd', default: '修改' },
                { btnType: 'info', type: 'qdInfo', default: '查看' },
              ];
            }
            const btn = arrs.map((item, index) => {
              return h(
                NButton,
                {
                  text: true,
                  size: 'small',
                  style: { margin: '10px' },
                  type: item.btnType,
                  onClick: () => handleClick(item.type, row),
                },
                { default: () => item.default }
              );
            });
            return btn;
          },
        },
      ],
      projectSubcolumns: [
        { title: '工程类型', align: 'center', key: 'projectTypeName' },
        { title: '工程子项名称', align: 'center', key: 'projectSubName' },
        { title: '工程父项名称', align: 'center', key: 'projectParentName' },
      ],
      findissuescolumns: [
        {
          title: '序号',
          align: 'center',
          width: '60',
          render(row, index) {
            return (paginationReactive.page - 1) * paginationReactive.pageSize + index + 1;
          },
        },
        { title: '考核子项目', align: 'center', key: 'subProjectName', width: '160' },
        { title: '考核指标', align: 'center', key: 'indexName', width: '160' },
        { title: '问题原因', align: 'center', key: 'questTypeName' },
        {
          title: '问题描述',
          align: 'center',
          key: 'questDesc',
          ellipsis: {
            tooltip: true,
          },
        },
        { title: '状态', align: 'center', key: 'statusDesc', width: '80' },
        { title: '扣分', align: 'center', key: 'cutScore', width: '60' },
        { title: '上报人', align: 'center', key: 'reportMan', width: '80' },
        { title: '上报时间', align: 'center', key: 'reportTime', width: '160' },
        { title: '整改人', align: 'center', key: 'dealMan', width: '80' },
        { title: '整改时间', align: 'center', key: 'dealTime', width: '160' },
        { title: '核销人', align: 'center', key: 'checkMan', width: '80' },
        { title: '核销时间', align: 'center', key: 'checkTime', width: '160' },
        {
          title: '操作',
          key: 'operation',
          align: 'center',
          width: '180',
          render(row) {
            let arrBtn = [];
            if (row.status == 0) {
              arrBtn = [
                { btnType: 'info', type: 'quesDetail', default: '查看' },
                { btnType: 'info', type: 'quesEdit', default: '修改' },
                { btnType: 'warning', type: 'quesDelete', default: '删除' },
              ];
            } else {
              arrBtn = [
                { btnType: 'info', type: 'quesEdit', default: '修改' },
                { btnType: 'info', type: 'quesDetail', default: '查看' },
                { btnType: 'warning', type: 'quesDelete', default: '删除' },
              ];
            }

            const btn = arrBtn.map((item, index) => {
              return h(
                NButton,
                {
                  text: true,
                  size: 'small',
                  style: { margin: '10px' },
                  type: item.btnType,
                  onClick: () => handleClick(item.type, row),
                },
                { default: () => item.default }
              );
            });
            return btn;
          },
        },
      ],
      actionColumn: [
        { btnType: 'primary', type: 'edit', default: '去考评' },
        { btnType: 'primary', type: 'editName', default: '修改考核名称' },
        { btnType: 'error', type: 'delete', default: '删除' },
      ],
    });
    //分页
    const paginationReactive = reactive({
      page: 1,
      pageSize: 10,
      showSizePicker: true,
      pageSizes: [10, 20, 50],
      showQuickJumper: true,
      pageCount: 0,
      itemCount: 0,
      prefix: () => {
        return '共 ' + paginationReactive.itemCount + ' 项';
      },
      onChange: (page) => {
        paginationReactive.page = page;
        getTableData();
      },
      onPageSizeChange: (pageSize) => {
        paginationReactive.pageSize = pageSize;
        paginationReactive.page = 1;
        getTableData();
      },
    });
    //获取表格数据
    const getTableData = async () => {
      allData.tableLoading = true;
      let pramas = {
        current: paginationReactive.page,
        size: paginationReactive.pageSize,
        performType: allData.searchVal1,
        yearMonth: formatDate(allData.searchTim1, 'YYYY-MM'),
      };
      let res = await AssessLSResultInfo(pramas);
      if (res && res.code == 200) {
        if (res.data == null) return;
        allData.tableData = res.data.records;
        res.data.records.forEach((item) => {
          if (item.performType == 0) {
            item.performType = '项目公司考核';
          } else {
            item.performType = '水务局考核';
          }
          if (item.type == 0) {
            item.type = '临时考核';
          } else {
            item.type = '常规考核';
          }
        });
        paginationReactive.pageCount = res.data.pages;
        paginationReactive.itemCount = res.data.total;
      }
      allData.tableLoading = false;
    };
    // 问题数列表分页
    const paginationReactive2 = reactive({
      page: 1,
      pageSize: 100,
      showSizePicker: true,
      pageSizes: [10, 20, 50],
      showQuickJumper: true,
      pageCount: 0,
      itemCount: 0,
      prefix: () => {
        return '共 ' + paginationReactive2.itemCount + ' 项';
      },
      onChange: (page) => {
        paginationReactive2.page = page;
        getKaopingNumData();
      },
      onPageSizeChange: (pageSize) => {
        paginationReactive2.pageSize = pageSize;
        paginationReactive2.page = 1;
        getKaopingNumData();
      },
    });
    // 问题清单分页
    const paginationReactive3 = reactive({
      page: 1,
      pageSize: 10,
      showSizePicker: true,
      pageSizes: [10, 20, 50],
      showQuickJumper: true,
      pageCount: 0,
      itemCount: 0,
      prefix: () => {
        return '共 ' + paginationReactive3.itemCount + ' 项';
      },
      onChange: (page) => {
        paginationReactive3.page = page;
        getNumData();
      },
      onPageSizeChange: (pageSize) => {
        paginationReactive3.pageSize = pageSize;
        paginationReactive3.page = 1;
        getNumData();
      },
    });

    const formRef = ref(null);
    const addProblemformRef = ref(null);
    const RectifyformRef = ref(null);
    const HXformRef = ref(null);
    const richEditor = ref(null);

    //获取工程类型
    const GetIndexClass = async () => {
      let res = await IndexsClassOne();
      let res4 = await AssessSelectInfo();
      if (res && res.code == 200) {
        let data = res.data;
        data.forEach((item) => {
          let { id, name } = item;
          allData.rangeOptions.push({ value: Number(id), label: name });
        });
      }
      if (res4 && res4.code == 200) {
        let data = res4.data;
        data.forEach((item) => {
          let { id, projectSubName } = item;
          allData.examineOptions.push({ value: Number(id), label: projectSubName });
        });
      }
    };
    //获取项目类型
    const getProjectType = async () => {
      let res1 = await getAllProjectType();
      if (res1 && res1.code == 200) {
        let data = res1.data;
        allData.deductypeOptions = data.map((item) => {
          return {
            value: item.codeId,
            label: item.codeName,
          };
        });
      }
      allData.problemcodeId = Number(allData.deductypeOptions[0].value);
      getSubProject();
    };
    //获取工程子项
    const getSubProject = async () => {
      let param = {
        codeId: allData.problemcodeId,
      };
      let res = await getSubProjectTypeByCodeId(param);
      if (res && res.code == 200) {
        let data = res.data;
        allData.subProjectOptions = data.map((item) => {
          return {
            value: item.subProjectId,
            label: item.subProjectName,
          };
        });
        allData.problemsubProjectId = Number(allData.subProjectOptions[0].value);
      }
      if (!!!allData.problemcodeId) {
        allData.problemsubProjectId = null;
      }
      getIndexsOne();
    };
    //获取指标类型
    const getIndexsOne = async () => {
      let param = {
        codeId: allData.problemcodeId,
        subProjectId: allData.problemsubProjectId,
      };
      allData.indexOneOptions = [];
      let res = await getIndexsOneListBySubProjectId(param);
      if (res && res.code == 200) {
        let data = res.data;
        allData.indexOneOptions = data.map((item) => {
          return {
            value: item.indexOne,
            label: item.indexOneName,
          };
        });
        allData.indexOneId = Number(allData.indexOneOptions[0].value);
      }
      if (!!!allData.problemcodeId || !!!allData.problemsubProjectId) {
        allData.indexOneId = null;
      }
    };
    // 问题批量保存成功之后操作
    function refreshData() {
      allData.addissueShow = false;
      getTableData(); //刷新主表格数据
      getKaopingNumData(); //刷新问题表格数据
      getKaopingData(); //刷新得分列表
      getNumData(); //刷新常规问题清单
    }
    // 点击事件
    const handleClick = async (type, row) => {
      switch (type) {
        case 'search':
          getTableData();
          break;
        case 'deductNum':
          paginationReactive3.page = 1;
          allData.deductShow = true;
          allData.mainId = row.id;
          getNumData();
          break;
        case 'searchproblem':
          getNumData();
          break;
        case 'addissues':
          // 问题新增
          allData.ifQuesUpdate = false;
          allData.addissueShow = true;
          break;
        case 'quesEdit':
          // 问题修改
          allData.updateQuesObj = { ...row };
          allData.ifQuesUpdate = true;
          allData.addissueShow = true;
          break;
        case 'editQuesqd':
          // 问题清单修改 editQuesqd
          allData.updateQuesObj = { ...row };
          allData.addFormValue.data.mainId = row.mainId;
          allData.addFormValue.data.indexId = row.indexId;
          allData.addFormValue.data.codeId = row.codeId;
          allData.addFormValue.data.indexscore = row.score;
          allData.addFormValue.data.relIndexIdType = row.relIndexIdType;
          allData.ifQuesUpdate = true;
          allData.addissueShow = true;
          break;
        case 'quesDelete':
          // 问题删除
          $dialog.info({
            title: '提示',
            content: `确定删除该问题数据吗?`,
            positiveText: '确定',
            negativeText: '取消',
            onPositiveClick: async () => {
              // 确定删除
              let res = await AssessCheckDelete({ id: row.id });
              if (res && res.code == 200) {
                refreshData(); //刷新数据
              }
            },
          });
          break;
        case 'saveissues':
          addProblemformRef.value.validate((errors) => {
            if (!errors) {
              saveNewProblem();
            } else {
              $message.error('验证失败,请检查必填项');
            }
          });
          break;
        case 'findissues':
          // 发现问题
          paginationReactive2.page = 1;
          allData.findissues = true;
          allData.issuesTitle = row.codeName + '——' + row.indexName + '问题扣分项';
          allData.addFormValue.data.mainId = row.mainId;
          allData.addFormValue.data.indexId = row.relIndexId;
          allData.addFormValue.data.codeId = row.codeId;
          allData.addFormValue.data.indexscore = row.score;
          allData.addFormValue.data.relIndexIdType = row.relIndexIdType;
          allData.scoreStandard = row.scoreStandard;
          getKaopingNumData();
          break;

        case 'rectify':
          allData.RectifyTitle = row.subProjectName + '整改';
          resetForm(allData.RectifyformInfo.data);
          allData.RectifyShow = true;
          allData.rectifyid = row.id;
          allData.uploadListZG = [];
          allData.RectifyformInfo.data.fileNo = [];
          break;

        case 'logout':
          allData.HXTitle = row.subProjectName + '核销';
          resetForm(allData.HXformInfo.data);
          allData.HXId = row.id;
          allData.HXShow = true;
          break;
        case 'hexiao':
          // 核销提交
          HXformRef.value.validate((errors) => {
            if (!errors) {
              CheckQuestions(allData.HXId);
            } else {
              $message.error('验证失败,请检查必填项');
            }
          });
          break;
        case 'quesDetail':
          // 问题详情查看
          allData.quesDetailId = row.id;
          allData.addissueDetailShow = true;
          break;

        case 'qdInfo':
          // 问题清单查看详情
          allData.quesDetailId = row.id;
          allData.addissueDetailShow = true;
          break;
        case 'add':
          allData.modalTitle = '新增临时考核';
          resetForm(allData.formInfo.data);
          allData.modalShow = true;
          allData.formInfo.data.yearMonth = new Date().getTime();
          allData.uploadList = [];
          allData.formInfo.data.fileNo = [];
          break;
        case 'projectSubCount':
          allData.projectShow = true;
          allData.oneLevelId = row.id;
          SelectSubProjectinfo();
          break;
        case 'edit':
          allData.kaopingShow = true;
          allData.oneLevelId = row.id;
          allData.kaopingTitle = row.performName;
          getKaopingRadio(); //获取考核范围
          break;
        case 'editName':
          // 修改考核名称
          allData.auditName = row.performName;
          $dialog.info({
            title: '提示',
            positiveText: '确定',
            negativeText: '取消',
            content: () => {
              return h(NInput, {
                value: allData.auditName,
                placeholder: '请输入考核名称',
                ['onUpdate:value']: (val) => {
                  allData.auditName = val;
                },
              });
            },
            onPositiveClick: async () => {
              let res = await AssessResultUpdate({ performName: allData.auditName, id: row.id });
              if (res && res.code == 200) {
                getTableData();
              }
            },
            onNegativeClick: async () => {},
          });
          break;
        case 'submit':
          formRef.value.validate((errors) => {
            if (!errors) {
              submitData();
            } else {
              $message.error('验证失败,请检查必填项');
            }
          });
          break;
        case 'rectifySave': //整改提交
          RectifyformRef.value.validate((errors) => {
            if (!errors) {
              rectifyProblem();
            } else {
              $message.error('验证失败,请检查必填项');
            }
          });
          break;
        case 'delete':
          $dialog.info({
            title: '提示',
            content: `确定删除该数据吗?`,
            positiveText: '确定',
            negativeText: '取消',
            onPositiveClick: () => {
              let ids = [row.id];
              dataDel(ids);
            },
          });
          break;
      }
    };
    // 问题清单导出
    const token = localStorage.getItem('tokenXF');
    function exportQues() {
      if (allData.tableListData.length == 0) {
        $message.error('表格数据为空,无法导出');
        return;
      }
      axios
        .get(`/api/perform/evaluatequestions/getQuestionsExcel`, {
          headers: {
            token: token,
          },
          responseType: 'blob',
          params: {
            mainId: allData.mainId,
            status: allData.problemStatus,
            codeId: allData.problemcodeId,
            subProjectId: allData.problemsubProjectId,
            indexOne: allData.indexOneId,
          },
        })
        .then(function (res) {
          downloadBlob(res.data, decodeURIComponent(res.headers['content-disposition'].split('filename=')[1]));
        });
    }
    // 点击问题数清单查看弹窗
    async function getNumData() {
      allData.tableLoadingQD = true;
      let param = {
        current: paginationReactive3.page,
        size: paginationReactive3.pageSize,
        mainId: allData.mainId,
        status: allData.problemStatus,
        codeId: allData.problemcodeId,
        subProjectId: allData.problemsubProjectId,
        indexOne: allData.indexOneId,
      };
      let res = await LSproblemList(param);
      if (res && res.code == 200) {
        allData.tableLoadingQD = false;
        let datas = res.data || [];
        allData.tableListData = datas.records;
        paginationReactive3.pageCount = datas.pages;
        paginationReactive3.itemCount = datas.total;
      }
    }
    //抽查子项详细信息
    async function SelectSubProjectinfo() {
      let params = {
        id: allData.oneLevelId,
      };
      let res = await SelectSubProject(params);
      if (res && res.code == 200) {
        allData.projectData = res.data;
      }
      allData.SubProjectLoading = false;
    }
    // 获取考评问题类型
    async function getKaopingRadio() {
      let params = {
        id: allData.oneLevelId,
      };
      let res = await RadioKaopingGetData(params);
      if (res && res.code == 200) {
        allData.radioArr = res.data || [];
        allData.kaopingtypeValue.Type = res.data[0].id || null;
      }
      getKaopingData();
    }
    //切换项目类型
    function changeSelect1(e) {
      allData.problemcodeId = e;
      getSubProject();
    }
    //切换考核项目
    function changeSelect2(e) {
      allData.problemsubProjectId = e;
      getIndexsOne();
    }
    //切换指标类型
    function changeSelect3(e) {
      allData.indexOneId = e;
    }
    // 问题类型点击切换
    function changeRadio(e) {
      allData.kaopingtypeValue.Type = e.target.value;
      getKaopingData();
    }
    //去考评查看弹窗内容
    async function getKaopingData() {
      allData.tableLoadingKP = true;
      let param = {
        mainId: allData.oneLevelId,
        levelOne: Number(allData.kaopingtypeValue.Type),
      };
      let res = await LSKaopingGetData(param);
      if (res && res.code == 200) {
        let datas = res.data || [];
        allData.kaopingtableData = datas;
        allData.tableLoadingKP = false;
      }
    }
    //去考评点击问题数查看详情
    async function getKaopingNumData() {
      allData.tableListLoading = true;
      let param = {
        current: paginationReactive2.page,
        size: paginationReactive2.pageSize,
        mainId: allData.addFormValue.data.mainId,
        indexId: allData.addFormValue.data.indexId,
        codeId: allData.addFormValue.data.codeId,
      };
      let res = await KaopingGetProblemData(param);
      if (res && res.code == 200) {
        allData.tableListLoading = false;
        let datas = res.data || [];
        allData.findissuesData = datas.records;
        paginationReactive2.pageCount = datas.pages;
        paginationReactive2.itemCount = datas.total || 0;
      }
    }

    // 删除数据
    async function dataDel(ids) {
      let res = await AssessResultDel({ ids: ids });
      if (res && res.code === 200) {
        $message.success('删除成功');
        getTableData();
      }
    }
    // 提交数据
    async function submitData() {
      let params = { ...allData.formInfo.data };
      params.yearMonth = formatDate(allData.formInfo.data.yearMonth, 'YYYY-MM');
      params.year = formatDate(allData.formInfo.data.yearMonth, 'YYYY');
      if (allData.modalTitle == '新增临时考核') {
        let res = await AssessLSResultSave(params);
        if (res && res.code == 200) {
          $message.success('操作成功');
          getTableData();
          allData.modalShow = false;
        }
      } else {
        let res = await AssessResultUpdate(params);
        if (res && res.code == 200) {
          $message.success('操作成功');
          getTableData();
          allData.modalShow = false;
        }
      }
    }
    // 提交新增问题
    async function saveNewProblem() {
      let params = { ...allData.addFormValue.data };
      let res = await addProblemSave(params);
      if (res && res.code == 200) {
        $message.success('操作成功');
        getKaopingNumData();
        allData.addissueShow = false;
      }
    }
    // 整改提交
    async function rectifyProblem() {
      let params = { ...allData.RectifyformInfo.data };
      params.dealTime = formatDate(allData.RectifyformInfo.data.dealTime, 'YYYY-MM-DD hh:mm:ss');
      params.id = allData.rectifyid;
      let res = await AssessRectification(params);
      if (res && res.code == 200) {
        $message.success('操作成功');
        getNumData();
        allData.RectifyShow = false;
      }
    }
    // 问题核销提交
    async function CheckQuestions(id) {
      let params = { ...allData.HXformInfo.data };
      params.checkTime = formatDate(allData.HXformInfo.data.checkTime, 'YYYY-MM-DD hh:mm:ss');
      params.id = id;
      let res = await AssessCheckQuestions(params);
      if (res && res.code === 200) {
        $message.success('核销成功');
        getNumData();
        allData.HXShow = false;
      }
    }
    // 现场问题文件上传和删除
    const changeFileXC = async (file) => {
      $loadingBar.start();
      if (file.event) {
        // 文件上传
        let formdata = new FormData();
        formdata.append('files', file.file.file);
        let config = {
          headers: { 'Content-Type': 'multipart/form-data' },
        };
        let res = await fileUpload(formdata, config);
        if (res && res.code === 200) {
          if (res.data.length > 0) {
            let datas = res.data[0];

            allData.addFormValue.data.fileNo.push(datas.fileNo);
            let param = {
              fileNo: datas.fileNo,
              name: datas.fileOriginalName,
              url: datas.fileCloudStorageKey,
              status: 'success',
            };
            allData.imageXC.push(param);
          }
        } else {
          allData.uploadListXC = [];
          let param = {
            id: file.file.id,
            name: file.file.name,
            status: 'error',
          };
          allData.uploadListXC.push(param);
        }
        $loadingBar.finish();
      } else {
        // 文件删除,根据文件名进行匹配
        let fileIndex = null;
        allData.imageXC.map((item, index) => {
          if (file.file.name == item.name) {
            fileIndex = index;
          }
        });
        let fileNos = [];
        fileNos.push(allData.imageXC[fileIndex].fileNo);
        let res = await fileDelete(fileNos);
        if (res && res.code === 200) {
          allData.addFormValue.data.fileNo.splice(fileIndex, 1);
        }
      }
    };
    // 整改现场图片文件上传和删除
    const changeFileZG = async (file) => {
      $loadingBar.start();
      if (file.event) {
        // 文件上传大小判断
        let size = file.file.file.size / 1024 / 1024;
        if (size > 10) {
          $message.error('图片大小大于10M,请删除后重新上传');
          setTimeout(() => {
            allData.uploadListZG = [
              {
                id: file.file.id,
                name: file.file.name,
                status: 'error',
              },
            ];
          });
          return false;
        }
        // 文件上传
        let formdata = new FormData();
        formdata.append('files', file.file.file);
        console.log(formdata);
        let config = {
          headers: { 'Content-Type': 'multipart/form-data' },
        };
        let res = await fileUpload(formdata, config);
        if (res && res.code === 200) {
          if (res.data.length > 0) {
            let datas = res.data[0];

            allData.RectifyformInfo.data.fileNo.push(datas.fileNo);
            let param = {
              fileNo: datas.fileNo,
              name: datas.fileOriginalName,
              url: datas.fileCloudStorageKey,
              status: 'success',
            };
            allData.imageZG.push(param);
          }
        } else {
          allData.uploadListZG = [];
          let param = {
            id: file.file.id,
            name: file.file.name,
            status: 'error',
          };
          allData.uploadListZG.push(param);
        }
        $loadingBar.finish();
      } else {
        // 文件删除,根据文件名进行匹配
        let fileIndex = null;
        allData.imageZG.map((item, index) => {
          if (file.file.name == item.name) {
            fileIndex = index;
          }
        });
        let fileNos = [];
        fileNos.push(allData.imageZG[fileIndex].fileNo);
        let res = await fileDelete(fileNos);
        if (res && res.code === 200) {
          allData.RectifyformInfo.data.fileNo.splice(fileIndex, 1);
        }
      }
    };
    // 获取人员
    async function getUserList() {
      allData.userOptions = [];
      let res = await allUserGet();
      if (res && res.code === 200) {
        res.data.map((item) => {
          allData.userOptions.push({
            value: item.userAccount,
            label: item.realName,
          });
        });
      }
    }
    onMounted(() => {
      getTableData();
      GetIndexClass();
      getProjectType();
      getUserList();
    });
    return {
      ...toRefs(allData),
      pagination: paginationReactive,
      pagination2: paginationReactive2,
      pagination3: paginationReactive3,
      handleClick,
      getTableData,
      changeFileXC,
      changeFileZG,
      getKaopingNumData,
      refreshData,
      changeRadio,
      changeSelect1,
      changeSelect2,
      changeSelect3,
      exportQues,
      formRef,
      richEditor,
      GetIndexClass,
      getSubProject,
      getIndexsOne,
      addProblemformRef,
      RectifyformRef,
      HXformRef,
      getProjectType,
    };
  },
};
</script>

<style lang="less" scoped>
.LinshiPage {
  width: 100%;
  .name {
    height: 34px;
    line-height: 34px;
  }
  .searchBoxs {
    margin: 10px;
  }
  .kaopingTable {
    border: 1px solid rgb(20, 217, 215);
  }
  .maker {
    border: 1px dashed rgba(194, 194, 194, 1);
    margin-bottom: 10px;
    padding: 10px;
    width: 100%;
  }
}
</style>