spring
2025-02-17 5d61e3ea816a74f4491276e2d73cca2e42af3b10
src/components/do/a6-device/check-and-accept.vue
@@ -1,147 +1,900 @@
<!-- 设备验收 -->
<template>
  <div>
    <div class="search">
      <div class="search_thing">
        <div class="search_label">关键字:</div>
        <div class="search_input"><el-input size="small" placeholder="请输入" clearable
            v-model="value" @keyup.enter.native="refreshTable()"></el-input></div>
        <div class="search_label">流程编号:</div>
        <div class="search_input"><el-input v-model="search.processNumber" clearable placeholder="请输入" size="small"
            @keyup.enter.native="getDeviceAList(clickNodeVal.value)"></el-input></div>
        <el-button size="small" style="margin-left: 10px" @click="resetSearch">重 置</el-button>
        <el-button size="small" type="primary" @click="getDeviceAList(clickNodeVal.value)">查 询</el-button>
      </div>
      <div class="search_thing" style="padding-left: 30px;">
        <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
      </div>
      <div class="btns">
        <el-button size="small" type="primary">新建</el-button>
        <el-button size="small" type="primary">导出</el-button>
      <div class="search_thing">
        <el-button size="small" type="primary" @click="dialogVisible = true">添加验收</el-button>
        <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">导出</el-button>
      </div>
    </div>
    <div class="tables" style="margin-top: 16px;">
      <ValueTable ref="ValueTable"
            :url="$api.auxiliaryWorkingHoursDay.selectAuxiliaryWorkingHoursDay"
            :delUrl="$api.auxiliaryWorkingHoursDay.deleteAuxiliaryWorkingHoursDay" :componentData="componentData" :key="upIndex"/>
    <div class="tables">
      <el-table ref="table" :data="tableDataAlist" height="100%">
        <el-table-column label="序号" type="index" width="60">
          <template v-slot="scope">
            <span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="流程编号" min-width="150" prop="processNumber" show-overflow-tooltip/>
        <el-table-column label="设备名称" min-width="140" prop="deviceName" show-overflow-tooltip/>
        <el-table-column label="管理编号" min-width="140" prop="managementNumber" show-overflow-tooltip/>
        <el-table-column label="序列号" min-width="80" prop="serialNumber" />
        <el-table-column label="提交者" min-width="100" prop="submitUser" />
        <el-table-column label="提交日期" min-width="150" prop="createTime" />
        <el-table-column label="当前状态" min-width="140" prop="currentState" />
        <el-table-column label="当前负责人" min-width="120" prop="currentResponsible" />
        <el-table-column fixed="right" label="操作" min-width="180">
          <template #default="{ row }">
            <el-button size="small" type="text" @click="handleAttachmentClick(row)">附件</el-button>
            <el-button size="small" type="text" @click="handleViewClick(row)">查看</el-button>
            <el-button size="small" type="text" @click="handleDownOne(row)">导出</el-button>
            <el-button size="small" type="text" @click="handleDeleteClick(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
        :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
        @current-change="handleCurrentChange">
      </el-pagination>
    </div>
    <!-- 添加设备故障记录 -->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible" title="仪器设备验收记录"
      width="60%" @open="openRecordAcceptance">
      <el-steps :active="currentStep" finish-status="success">
        <el-step v-for="(v, i) in steps" :key="i" :title="v" style="cursor:pointer"
          @click.native="choiceStep(i)"></el-step>
      </el-steps>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <div v-show="currentStepClick === 0">
          <el-card style="margin-top: 1em; height: 56vh; overflow-y: scroll;">
            <!-- 新增设备事记录卡片 -->
            <el-row>
              <el-col :span="24">
                <el-form-item label="流程编号:" prop="processNumber">
                  <el-input v-model="form.processNumber" disabled size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="设备名称:">
                  <el-input v-model="form.deviceName" disabled size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="生产厂家:">
                  <el-input v-model="form.manufacturer" disabled size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="设备型号:">
                  <el-input v-model="form.specificationModel" disabled size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="管理编号:">
                  <el-input v-model="form.managementNumber" disabled size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item :rules="[{ required: currentStep === 0, message: '请输入序列号', trigger: 'blur' }]" label="序列号:"
                  prop="serialNumber">
                  <el-input v-model="form.serialNumber" :disabled="currentStep !== 0" size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item :rules="[{ required: currentStep === 0, message: '请输入设备类别', trigger: 'change' }]" label="设备类别:"
                  prop="deviceClass">
                  <el-radio-group v-model="form.deviceClass" :disabled="currentStep !== 0">
                    <el-radio label="0precision">精密型设备</el-radio>
                    <el-radio label="1conventional">常规设备</el-radio><br />
                    <el-radio label="2auxiliary_class">辅助类设备</el-radio>
                    <el-radio label="4environmental">环境类设备</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 0, message: '请输入开箱前检查外包装有无破损', trigger: 'blur' }]" label="开箱前检查外包装有无破损:" label-width="220px"
                  prop="checkOuterPackaging">
                  <el-input v-model="form.checkOuterPackaging" :disabled="currentStep !== 0" size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="相关附件:" prop="fileName">
                  <el-input v-model="form.fileName" :style="`width: ${currentStep == 0 ? '88%' : '100%'};`" disabled
                    size="small">
                    <el-button v-if="currentStep === 0" slot="append" icon="el-icon-delete-solid"
                      @click="deleteFile"></el-button>
                  </el-input>
                  <el-upload ref="upload" :action="action" :on-success="onSuccess" :show-file-list="false"
                    style="float: right;">
                    <el-button v-if="currentStep === 0" slot="trigger" class="uploadFile" size="small"
                      style="position: relative;top: -4px" type="primary">附件上传</el-button>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 0, message: '请选择下环节责任人', trigger: 'change' }]" label="下环节责任人:"
                  prop="submitNextPesponsible">
                  <el-select v-model="form.submitNextPesponsible" :disabled="currentStep !== 0" clearable filterable
                    placeholder="请选择下环节负责人" size="small" style="width: 50%;">
                    <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item :rules="[{ required: currentStep === 0, message: '请输入设备开箱验收结论', trigger: 'change' }]" label="设备开箱验收结论:" label-width="150px"
                  prop="unpackingAcceptanceConclusion">
                  <el-radio-group v-model="form.unpackingAcceptanceConclusion" :disabled="currentStep !== 0">
                    <el-radio :label="'0qualified'">合格</el-radio>
                    <el-radio :label="'1unqualified'">不合格,缺少备件供应商补发</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <div style="margin-bottom: 20px; width: 100%;">
                  <label>备件确认:</label>
                  <el-button v-if="currentStep === 0" size="small" style="float: right;"
                    type="primary" @click="addTableRow('sparePartsConfirmationList')">增加行</el-button>
                </div>
                <el-table :data="form.sparePartsConfirmationList" border stripe style="width: 100%; min-height: 30vh">
                  <el-table-column label="序号" prop="序号" type="index" width="80" />
                  <el-table-column label="名称" min-width="120" prop="name">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 0" v-model="scope.row.name" size="small"></el-input>
                      <label v-else>{{ scope.row.name }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column label="数量" min-width="120" prop="number">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 0" v-model="scope.row.number" size="small"></el-input>
                      <label v-else>{{ scope.row.number }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column label="备注" min-width="120" prop="note">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 0" v-model="scope.row.note" size="small"></el-input>
                      <label v-else>{{ scope.row.note }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column v-if="currentStep === 0" fixed="right" label="操作" width="90">
                    <template slot-scope="scope">
                      <el-button icon="el-icon-delete" type="text"
                        @click="deleteRow(scope.$index, scope.row, 'sparePartsConfirmationList')">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
              <el-col :span="24">
                <div style="margin: 20px 0; width: 100%;">
                  <label>文件类确认:</label>
                  <el-button v-if="currentStep === 0" size="small" style="float: right;"
                    type="primary" @click="addTableRow('fileClassConfirmationList')">增加行</el-button>
                </div>
                <el-table :data="form.fileClassConfirmationList" border stripe style="width: 100%; min-height: 30vh">
                  <el-table-column label="序号" prop="序号" type="index" width="80" />
                  <el-table-column label="应有册数" min-width="120" prop="expectedCopies">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 0" v-model="scope.row.expectedCopies" size="small"></el-input>
                      <label v-else>{{ scope.row.expectedCopies }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column label="实际收到册数" min-width="120" prop="actualCopies">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 0" v-model="scope.row.actualCopies" size="small"></el-input>
                      <label v-else>{{ scope.row.actualCopies }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column v-if="currentStep === 0" fixed="right" label="操作" width="90">
                    <template v-slot="scope">
                      <el-button icon="el-icon-delete" type="text"
                        @click="deleteRow(scope.$index, scope.row, 'fileClassConfirmationList')">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
              <el-col :span="24" style="margin-top: 10px;">
                <el-form-item label="备注:" label-width="90px">
                  <el-input v-model="form.submitRemarks" :disabled="currentStep !== 0" size="small"
                    type="textarea"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4">
              操作人:{{ form.submitOperatingPersonnel }}
            </el-col>
            <el-col :span="6">
              日期:{{ form.submitDate }}
            </el-col>
          </el-row>
        </div>
        <div v-show="currentStepClick === 1">
          <el-card style="margin-top: 1em; height: 56vh; overflow-y: scroll;">
            <el-row>
              <el-col :span="24">
                <el-form-item label="复核意见:" prop="accidentDescription">
                  <el-input v-model="form.unpackingReviewOpinion" :disabled="currentStep !== 1" size="small"
                    type="textarea"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 1, message: '请输入下环节责任人', trigger: 'change' }]" label="下环节责任人:"
                  prop="unpackingNextPesponsible">
                  <el-select v-model="form.unpackingNextPesponsible" :disabled="currentStep !== 1" clearable filterable
                    placeholder="请选择下环节负责人" size="small" style="width: 50%;">
                    <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4">
              操作人:{{ form.unpackingOperatingPersonnel }}
            </el-col>
            <el-col :span="6">
              日期:{{ form.unpackingDate }}
            </el-col>
          </el-row>
        </div>
        <div v-show="currentStepClick === 2">
          <el-card style="margin-top: 1em; height: 56vh; overflow-y: scroll;">
            <el-row>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 2, message: '请输入安装位置', trigger: 'blur' }]" label="安装位置:"
                  prop="installLocation">
                  <el-input v-model="form.installLocation" :disabled="currentStep !== 2" clearable placeholder="请输入安装位置"
                    size="small"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="备注:">
                  <el-input v-model="form.installRemarks" :disabled="currentStep !== 2" size="small"
                    type="textarea"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 2, message: '请输入下环节责任人', trigger: 'blur' }]" label="下环节责任人:"
                  prop="installNextPesponsible">
                  <el-select v-model="form.installNextPesponsible" :disabled="currentStep !== 2" clearable filterable
                    placeholder="请选择下环节负责人" size="small" style="width: 50%;">
                    <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <div style="margin-bottom: 20px; width: 100%;">
                  <label>安装验收记录</label>
                  <el-button v-if="currentStep === 2" size="small" style="float: right;"
                    type="primary" @click="addTableRow('installationAcceptanceRecordList')">增加行</el-button>
                </div>
                <el-table :data="form.installationAcceptanceRecordList" border stripe
                  style="width: 100%; min-height: 30vh">
                  <el-table-column label="序号" prop="序号" type="index" width="80" />
                  <el-table-column label="项目" min-width="120" prop="installationProject">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 2" v-model="scope.row.installationProject"
                        size="small"></el-input>
                      <label v-else>{{ scope.row.installationProject }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column label="安装情况" min-width="120" prop="installationSituation">
                    <template v-slot="scope">
                      <el-input v-if="currentStep === 2" v-model="scope.row.installationSituation"
                        size="small"></el-input>
                      <label v-else>{{ scope.row.installationSituation }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column label="安装完成" min-width="120" prop="installationCompleted">
                    <template v-slot="scope">
                      <el-select v-if="currentStep === 2" v-model="scope.row.installationCompleted" placeholder="请选择">
                        <el-option label="是" value="0yes"></el-option>
                        <el-option label="否" value="1no"></el-option>
                      </el-select>
                      <label v-else>{{ scope.row.installationCompleted === '0yes' ? '是' :
                        scope.row.installationCompleted === '1no' ? '否' : '' }}</label>
                    </template>
                  </el-table-column>
                  <el-table-column v-if="currentStep === 2" fixed="right" label="操作" width="90">
                    <template slot-scope="scope">
                      <el-button icon="el-icon-delete" type="text"
                        @click="deleteRow(scope.$index, scope.row, 'installationAcceptanceRecordList')">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4">
              操作人:{{ form.installOperatingPersonnel }}
            </el-col>
            <el-col :span="6">
              日期:{{ form.installDate }}
            </el-col>
          </el-row>
        </div>
        <div v-show="currentStepClick === 3">
          <el-card style="margin-top: 1em; height: 56vh; overflow-y: scroll;">
            <el-row>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 3, message: '请输入复合意见', trigger: 'blur' }]" label="复合意见:"
                  prop="installationAcceptanceCompoundOpinion">
                  <el-input v-model="form.installationAcceptanceCompoundOpinion" :disabled="currentStep !== 3"
                    size="small" type="textarea"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 3, message: '请输入下环节负责人', trigger: 'change' }]" label="下环节责任人:"
                  prop="installationAcceptanceNextPesponsible">
                  <el-select v-model="form.installationAcceptanceNextPesponsible" :disabled="currentStep !== 3" clearable
                    filterable placeholder="请选择下环节负责人" size="small" style="width: 50%;">
                    <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.name">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4">
              操作人:{{ form.installationAcceptanceOperatingPersonnel }}
            </el-col>
            <el-col :span="6">
              日期:{{ form.installationAcceptanceDate }}
            </el-col>
          </el-row>
        </div>
        <div v-show="currentStepClick === 4">
          <el-card style="margin-top: 1em; height: 56vh; overflow-y: scroll;">
            <div style="margin-bottom: 20px; width: 100%;">
              <label>验收核查记录:</label>
              <el-button v-if="currentStep === 4" size="small" style="float: right;"
                type="primary" @click="addTableRow('acceptanceCheckRecordList')">增加行</el-button>
            </div>
            <el-table :data="form.acceptanceCheckRecordList" border style="width: 100%; min-height: 30vh">
              <el-table-column label="序号" prop="sequence" width="80">
              </el-table-column>
              <el-table-column label="仪器模块" min-width="120" prop="instrumentModule">
                <template v-slot="scope">
                  <el-input v-if="currentStep === 4" v-model="scope.row.instrumentModule" size="small"></el-input>
                  <label v-else>{{ scope.row.instrumentModule }}</label>
                </template>
              </el-table-column>
              <el-table-column label="核查参数" min-width="120" prop="verificationParameter">
                <template v-slot="scope">
                  <el-input v-if="currentStep === 4" v-model="scope.row.verificationParameter" size="small"></el-input>
                  <label v-else>{{ scope.row.verificationParameter }}</label>
                </template>
              </el-table-column>
              <el-table-column label="可接收限" min-width="120" prop="acceptableLimit">
                <template v-slot="scope">
                  <el-input v-if="currentStep === 4" v-model="scope.row.acceptableLimit" size="small"></el-input>
                  <label v-else>{{ scope.row.acceptableLimit }}</label>
                </template>
              </el-table-column>
              <el-table-column label="核查结果" min-width="120" prop="verificationResult">
                <template v-slot="scope">
                  <el-input v-if="currentStep === 4" v-model="scope.row.verificationResult" size="small"></el-input>
                  <label v-else>{{ scope.row.verificationResult }}</label>
                </template>
              </el-table-column>
              <el-table-column label="核查结论" min-width="120" prop="verificationConclusion">
                <template v-slot="scope">
                  <el-select v-if="currentStep === 4" v-model="scope.row.verificationConclusion" placeholder="请选择">
                    <el-option label="符合" value="0accordWith"></el-option>
                    <el-option label="不符合" value="1inconformity"></el-option>
                  </el-select>
                  <label v-else>{{ scope.row.verificationConclusion }}</label>
                </template>
              </el-table-column>
              <el-table-column v-if="currentStep === 4" fixed="right" label="操作" width="90">
                <template slot-scope="scope">
                  <el-button size="small" type="text"
                    @click="deleteRow(scope.$index, scope.row, 'acceptanceCheckRecordList')">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-form-item :rules="[{ required: currentStep === 4, message: '请输入设备开箱验收结论', trigger: 'change' }]" label="设备开箱验收结论:"
              label-width="150px" prop="acceptanceCheckUnpackingConclusion">
              <el-radio-group v-model="form.acceptanceCheckUnpackingConclusion" :disabled="currentStep !== 4">
                <el-radio :label="'0qualified'">合格</el-radio>
                <el-radio :label="'1unqualified'">不合格,缺少备件供应商补发</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item :rules="[{ required: currentStep === 4, message: '请输入下环节责任人', trigger: 'change' }]" label="下环节责任人:"
              prop="acceptanceCheckNextPesponsible">
              <el-select v-model="form.acceptanceCheckNextPesponsible" :disabled="currentStep !== 4" clearable
                filterable placeholder="请选择下环节负责人" size="small" style="width: 50%;">
                <el-option v-for="item in responsibleOptions" :key="item.value" :label="item.label" :value="item.name">
                </el-option>
              </el-select>
            </el-form-item>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4">
              操作人:{{ form.acceptanceCheckOperatingPersonnel }}
            </el-col>
            <el-col :span="6">
              日期:{{ form.acceptanceCheckDate }}
            </el-col>
          </el-row>
        </div>
        <div v-show="currentStepClick === 5">
          <el-card style="margin-top: 1em; height: 56vh; overflow-y: scroll;">
            <el-row>
              <el-col :span="24">
                <el-form-item :rules="[{ required: currentStep === 5, message: '请输入审核意见', trigger: 'blur' }]" label="审核意见:"
                  prop="acceptanceAuditAuditOpinion">
                  <el-input v-model="form.acceptanceAuditAuditOpinion" :disabled="currentStep !== 5" size="small"
                    type="textarea"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-card>
          <el-row style="margin-top: 1em;">
            <el-col :span="4">
              操作人:{{ form.acceptanceAuditOperatingPersonnel }}
            </el-col>
            <el-col :span="6">
              日期:{{ form.acceptanceAuditDate }}
            </el-col>
          </el-row>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="currentStep !== 0 && currentStep !== 6" @click="submitForm('3reject')">驳回</el-button>
        <el-button v-if="currentStep === 0" @click="submitForm('2save')">保存</el-button>
        <el-button v-if="currentStep !== 6" type="primary" @click="submitForm('1submit')">{{ currentStep === 0 ? '提交' :
          '通过'
          }}</el-button>
      </span>
    </el-dialog>
  </div>
  <!-- 查单编辑框 -->
</template>
<script>
import ValueTable from '../../tool/value-table.vue'
import { dateFormat } from '../../../util/date'
import file from '../../../util/file';
export default {
  components: {
    ValueTable
  },
  data(){
    return {
      value:'',
      componentData: {
        entity: {
          week: null,
          weekDay: null,
          dateTime: null,
          name:null,
          orderBy: {
            field: 'id',
            order: 'desc'
          }
        },
        isIndex: true,
        showSelect: false,
        select: false,
        do: [{
          id: 'getFile',
          font: '附件',
          type: 'text',
          method: 'getFile'
        }, {
          id: 'handleLook',
          font: '查看',
          type: 'text',
          method: 'handleLook'
        },{
          id: 'delete',
          font: '删除',
          type: 'text',
          method: 'doDiy',
          disabFun: (row, index) => {
            return row.state === '已审核' || row.state === '已批准'
          }
        }],
        tagField: {
          shift:{
            select:[]
          },
          state:{
            select:[
              {
                label:'已提交',
                value:'已提交',
                type:'primary'
              },
              {
                label:'已审核',
                value:'已审核',
                type:'warning'
              },
              {
                label:'已批准',
                value:'已批准',
                type:'success'
              },
            ]
          },
          weekDay:{
            select:[]
          }
        },
        linkEvent: {},
        selectField: {
          shift:{
            select:[]
          },
          state:{
            select:[
              {
                label:'已提交',
                value:'已提交',
                type:'primary'
              },
              {
                label:'已审核',
                value:'已审核',
                type:'warning'
              },
              {
                label:'已批准',
                value:'已批准',
                type:'success'
              },
            ]
          },
          weekDay:{
            select:[]
          }
        },
        requiredAdd: [],
        requiredUp: []
         },
      upIndex:0,
  props: {
    clickNodeVal: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  methods:{
    refreshTable(){}
  data() {
    return {
      //事故设备信息
      tableDataAlist: [], // 更改变量名称
      dialogVisible: false,
      rules: {
        quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
      },
      currentStep: 0, // 步骤条显示第几步
      currentStepClick: 0, // 点击步骤条变化
      steps: ['提交', '开箱验收复核', '安装验收检查', '安装验收复核', '验收核查', '验收核查审核'],
      form: {
        sparePartsConfirmationList: [], // 备件确认List
        fileClassConfirmationList: [], // 文件确认List
        installationAcceptanceRecordList: [], // 安装验收记录
        acceptanceCheckRecordList: [], // 验收核查记录
        fileName: '', // 文件名称
        systemFileName: '', // 系统文件名称
      },
      outLoading: false,
      responsibleOptions: [], // 下环节负责人list
      isUpdate: false,
      search: {
        size: 20,
        current: 1,
        total: 0,
        processNumber: '',
      },
    }
  },
  computed: {
    action() {
      return this.javaApi + this.$api.personnel.saveCNASFile
    }
  },
  mounted() {
    // 获取设备事故信息
    this.getDeviceAList(this.clickNodeVal.value);
    window.excelClosed = this.closed
  },
  methods: {
    handleSizeChange(val) {
      this.search.size = val
      this.getPersonnelTraining(this.clickNodeVal.value);
    },
    handleCurrentChange(val) {
      this.search.current = val
      this.getPersonnelTraining(this.clickNodeVal.value);
    },
    deleteFile() {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.personnel.deleteCNASFile + "?fileName=" + this.form.systemFileName).then(res => {
          if (res.code == 200) {
            this.$message.success('删除成功!')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    onSuccess(response, file, fileList) {
      if (response.code == 200) {
        // 在保存赋值新文件
        this.form.fileName = file.name
        this.form.systemFileName = response.data
      } else {
        this.$message.error(response.message)
      }
    },
    addTableRow(value) {
      switch (value) {
        // 备件确认
        case 'sparePartsConfirmationList':
          const obj = Object.assign({
            name: '',
            number: null,
            note: ''
          })
          this.form.sparePartsConfirmationList.push(obj)
          break
        // 文件确认List
        case 'fileClassConfirmationList':
          const obj1 = Object.assign({
            expectedCopies: '',
            actualCopies: '',
          })
          this.form.fileClassConfirmationList.push(obj1)
          break
        // 安装验收记录
        case 'installationAcceptanceRecordList':
          const obj2 = Object.assign({
            installationProject: '',
            installationSituation: '',
            installationCompleted: ''
          })
          this.form.installationAcceptanceRecordList.push(obj2)
          break
        // 验收核查记录
        case 'acceptanceCheckRecordList':
          const obj3 = Object.assign({
            instrumentModule: '',
            verificationParameter: '',
            acceptableLimit: '',
            verificationResult: '',
            verificationConclusion: ''
          })
          this.form.acceptanceCheckRecordList.push(obj3)
        default:
          break
      }
    },
    deleteRow(index, row, type) {
      switch (type) {
        // 备件确认
        case 'sparePartsConfirmationList':
          if (row.sparePartsId) {
            this.$axios.delete(this.$api.deviceCheck.deleteIncidentReportAll + '?sparePartsId=' + row.sparePartsId).then(res => { });
          }
          this.form.sparePartsConfirmationList.splice(index, 1)
          this.$message.success('删除成功!')
          break
        // 文件确认List
        case 'fileClassConfirmationList':
          if (row.fileId) {
            this.$axios.delete(this.$api.deviceCheck.deleteIncidentReportAll + '?fileId=' + row.fileId).then(res => { });
          }
          this.form.fileClassConfirmationList.splice(index, 1)
          this.$message.success('删除成功!')
          break
        // 安装验收记录
        case 'installationAcceptanceRecordList':
          if (row.installId) {
            this.$axios.delete(this.$api.deviceCheck.deleteIncidentReportAll + '?installId=' + row.installId).then(res => { });
          }
          this.form.installationAcceptanceRecordList.splice(index, 1)
          this.$message.success('删除成功!')
          break
        // 验收核查记录
        case 'acceptanceCheckRecordList':
          if (row.acceptanceCheckId) {
            this.$axios.delete(this.$api.deviceCheck.deleteIncidentReportAll + '?acceptanceCheckId=' + row.acceptanceCheckId).then(res => { });
          }
          this.form.acceptanceCheckRecordList.splice(index, 1)
          this.$message.success('删除成功!')
        default:
          break
      }
    },
    choiceStep(index) {
      this.currentStepClick = index
    },
    openRecordAcceptance() {
      // 获取设备基础信息
      this.$axios.get(this.$api.deviceScope.selectDeviceByCode + '?id=' + this.clickNodeVal.value).then(res => {
        this.form.deviceName = res.data.deviceName
        this.form.manufacturer = res.data.manufacturer
        this.form.specificationModel = res.data.specificationModel
        this.form.managementNumber = res.data.managementNumber
        this.$nextTick(() => {
          this.$refs['form'].clearValidate()
        })
      });
      // 获取负责人信息
      this.getUserList()
    },
    //提交表单
    async submitForm(saveState) {
      this.$refs.form.validate((valid) => {
        if (valid === true || saveState !== '1submit') {
          // 给当前环节设置创建人与时间
          let user = JSON.parse(localStorage.getItem('user'))
          const dateTime = dateFormat(new Date())
          // 获取当前环节操作人与日期
          switch (this.currentStep) {
            case 0:
              this.form.submitOperatingPersonnel = user.name
              this.form.submitDate = dateTime
              break
            case 1:
              this.form.unpackingOperatingPersonnel = user.name
              this.form.unpackingDate = dateTime
              break
            case 2:
              this.form.installOperatingPersonnel = user.name
              this.form.installDate = dateTime
              break
            case 3:
              this.form.installationAcceptanceOperatingPersonnel = user.name
              this.form.installationAcceptanceDate = dateTime
              break
            case 4:
              this.form.acceptanceCheckOperatingPersonnel = user.name
              this.form.acceptanceCheckDate = dateTime
              break
            case 5:
              this.form.acceptanceAuditOperatingPersonnel = user.name
              this.form.acceptanceAuditDate = dateTime
              break
            default:
              break
          }
          // 获取当前环节负责人
          switch (saveState === '3reject' ? this.currentStep - 1 : this.currentStep) {
            case 0:
              this.form.currentResponsible = this.form.submitNextPesponsible
              break
            case 1:
              this.form.currentResponsible = this.form.unpackingNextPesponsible
              break
            case 2:
              this.form.currentResponsible = this.form.installNextPesponsible
              break
            case 3:
              this.form.currentResponsible = this.form.installationAcceptanceNextPesponsible
              break
            case 4:
              this.form.currentResponsible = this.form.acceptanceCheckNextPesponsible
              break
            default:
              break
          }
          let currentStepAction;
          // 设置该操作判断是否为提交,保存,驳回,通过
          switch (saveState) {
            // 提交,通过
            case '1submit':
              currentStepAction = this.currentStep + 1
              break
            // 保存
            case '2save':
              currentStepAction = this.currentStep
              break
            // 驳回
            case '3reject':
              currentStepAction = this.currentStep - 1
              break
            default:
              break
          }
          // 获取当前状态
          this.form.currentState = currentStepAction === 6 ? '关闭' : this.steps[currentStepAction]
          this.form.deviceId = this.clickNodeVal.value
          this.$axios.post(this.$api.deviceCheck.saveIncidentReportData, this.form, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
            if (res.code == 200) {
              this.$message.success('提交成功')
              this.getDeviceAList(this.clickNodeVal.value);
              this.dialogVisible = false
            }
          })
        } else {
          let step = this.steps[this.currentStep]
          this.$message.warning(step + '  流程中有必填项未填!');
        }
      });
    },
    // 获取负责人信息接口
    getUserList() {
      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
        if (res.code == 200) {
          this.responsibleOptions = res.data
        }
      })
    },
    resetSearch() {
      this.search = {
        size: 20,
          current: 1,
          total: 0,
          processNumber: '',
      }
      this.getDeviceAList(this.clickNodeVal.value);
    },
    // 获取设备事故信息(根据从vuex中获取到的设备名称id进行数据查询)
    getDeviceAList(deviceId) {
      this.$axios.get(this.$api.deviceCheck.incidentReportPage + "?deviceId=" + deviceId + "&size=" + this.search.size + "&current=" + this.search.current + "&processNumber=" + this.search.processNumber).then(res => {
        if (res.code == 200) {
          this.tableDataAlist = res.data.records
          this.search.total = res.data.total
        }
      })
    },
    //table 事件处理开始处
    handleAttachmentClick(row) {
      // 模拟下载附件
      const imageUrl = this.javaApi+'/img/'+row.systemFileName; // 图片 URL
      // downloadImage(imageUrl);
      file.downloadIamge(imageUrl,row.fileName)
    },
    handleViewClick(row) {
      this.$axios.get(this.$api.deviceCheck.getShowIncidentReport + "?id=" + row.id).then(res => {
        this.form = { ...res.data }
        // 如果索引为6表示全部通过
        this.currentStep = this.steps.indexOf(this.form.currentState) === -1 ? 6 : this.steps.indexOf(this.form.currentState)
        this.currentStepClick = this.currentStep === 6 ? 0 : this.currentStep
        this.$nextTick(() => {
          this.$refs['form'].clearValidate()
        })
      })
      this.dialogVisible = true
    },
    // 导出
    handleDownOne(row) {
      this.outLoading = true
      this.$axios.get(this.$api.deviceCheck.acceptanceCertificateExport + '?deviceId=' + row.deviceId + '&processNumber=' + row.processNumber, {
        responseType: "blob"
      }).then(res => {
        this.outLoading = false
        this.$message.success('导出成功')
        const blob = new Blob([res], { type: 'application/octet-stream' });
        const url = URL.createObjectURL(blob);
        const link = document.createElement('a');
        link.href = url;
        link.download = '设备验收.doc';
        link.click();
      })
    },
    // 删除
    handleDeleteClick(row) {
      this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.deviceCheck.deleteIncidentReport + '?id=' + row.id).then(res => {
          if (res.code == 200) {
            this.$message.success('删除成功')
            this.getDeviceAList(this.clickNodeVal.value);
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    //导出
    handleDown() {
      this.outLoading = true
      this.$axios.get(this.$api.deviceCheck.incidentReportExport + '?deviceId=' + this.clickNodeVal.value, {
        responseType: "blob"
      }).then(res => {
        this.outLoading = false
        this.$message.success('导出成功')
        const blob = new Blob([res], { type: 'application/octet-stream' });
        const url = URL.createObjectURL(blob);
        const link = document.createElement('a');
        link.href = url;
        link.download = '设备验收.xlsx';
        link.click();
      })
    },
  },
  watch: {
    // 监听点击el-tree的数据,进行数据刷新
    clickNodeVal(newVal) {
      if (newVal.value) {
        this.getDeviceAList(newVal.value);
      }
    },
    dialogVisible(newVal) {
      if (!newVal) {
        this.form = {
          sparePartsConfirmationList: [], // 备件确认List
          fileClassConfirmationList: [], // 文件确认List
          installationAcceptanceRecordList: [], // 安装验收记录
          acceptanceCheckRecordList: [], // 验收核查记录
          fileName: '', // 文件名称
          systemFileName: '', // 系统文件名称
        }
        this.currentStep = 0 // 步骤条显示第几步
        this.currentStepClick = 0 // 点击步骤条变化
        this.$refs['form'].clearValidate()
      }
    }
  }
}
function downloadImage(url) {
  const link = document.createElement('a');
  link.href = url;
  link.download = 'attachment.jpg'; // 文件名
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}
</script>
<style scoped>
.tables{
  width: calc(100vw - 390px);
  height: calc(100vh - 230px);
>>>.el-radio {
  color: #606266;
  font-weight: 500;
  cursor: pointer;
  margin-right: 0px;
  width: 10em;
}
.tables {
  width: 100%;
  height: calc(100vh - 17em);
}
.search {
  background-color: #fff;
  height: 40px;
  display: flex;
  align-items: center;
  position: relative;
  justify-content: space-between;
}
.search_thing {
@@ -151,18 +904,28 @@
}
.search_label {
  width: 70px;
  font-size: 14px;
  text-align: right;
  width: 110px;
}
.search_input {
  width: calc(100% - 120px);
}
.btns{
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translate(0,-50%);
.search_thing {
  display: flex;
  margin: 10px 0;
}
.line {
  width: 20px;
  height: 1px;
  background-color: #ccc;
  display: inline-block;
  margin-right: 10px;
}
.form .search_label {
  width: 120px;
}
</style>