lxp
2025-03-12 5f32b360c5cc299d5ce9a94b812b34703184f2d0
src/views/CNAS/resourceDemand/device/component/check.vue
@@ -4,7 +4,7 @@
    <div class="btns">
      <el-button size="small" type="primary" @click="calibrationMaintenance()">核查项目维护</el-button>
      <el-button size="small" type="primary" @click="add('add')">添加核查记录</el-button>
      <el-button size="small" type="primary">导出Excel</el-button>
      <el-button size="small" type="primary" @click="downLoadPost">导出Excel</el-button>
    </div>
    <div class="tables" style="margin-top: 16px;">
      <el-table :data="tableData" height="calc(100vh - 20em)">
@@ -42,14 +42,15 @@
    </div>
    <!-- 校准项目维护 -->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible0"
      title="核查项目维护" top="5vh" width="70%">
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible0" title="核查项目维护"
               top="5vh" width="70%">
      <h4>
        <span style="display: flex;align-items: center;"><span class="line"></span><span>设备核查参数维护</span></span>
        <el-button :loading="addCalibrateLoading" size="small" type="primary" @click="addCalibrate">添 加</el-button>
      </h4>
      <div>
        <el-form ref="form0" :model="form0" :rules="form0Rules" label-position="right" label-width="120px">
        <el-form ref="form0" :model="form0" :rules="form0Rules"
                 label-position="right" label-width="120px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="核查参数:" prop="measurementParameter">
@@ -78,8 +79,9 @@
        <span style="display: flex;align-items: center;"><span class="line"></span><span>设备核查参数</span></span>
      </h4>
      <!-- 设备校准参数表格 -->
      <el-table ref="calibrateTable" v-loading="calibrateParamsLoading" :data="calibrateParams" max-height="450" stripe
        style="width: 100%">
      <el-table ref="calibrateTable" v-loading="calibrateParamsLoading" :data="calibrateParams"
                max-height="450"
                stripe style="width: 100%">
        <el-table-column label="编号" type="index" width="80"></el-table-column>
        <el-table-column label="核查参数" prop="measurementParameter"></el-table-column>
        <el-table-column label="核查范围" prop="rangeOfMeasurement"></el-table-column>
@@ -96,68 +98,71 @@
    </el-dialog>
    <!-- 添加核查记录 -->
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible1"
      title="添加核查记录" top="5vh" width="80%" @close="resetcalibrationRecord">
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible1" title="核查记录" :before-close="handleClose"
               top="5vh"
               width="80%" @close="resetcalibrationRecord">
      <div class="dialog-content">
        <h4>
          <span style="display: flex;align-items: center;">
            <span class="line"></span>
           <span class="line"></span>
            <span>添加设备核查记录</span>
          </span>
        </h4>
        <el-form ref="calibrationRecord" :model="calibrationRecord" :rules="formRules" label-position="right"
          label-width="120px">
        <el-form ref="calibrationRecord" :model="calibrationRecord" :rules="formRules"
                 label-position="right" label-width="120px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="核查人:" prop="unitOfMeasure">
                <el-input v-model="calibrationRecord.unitOfMeasure" :disabled="operationType === 'view'"
                  size="small"></el-input>
                          size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="核查日期:" prop="calibrationDate">
                <el-date-picker v-model="calibrationRecord.calibrationDate" :disabled="operationType === 'view'"
                  format="yyyy-MM-dd" placeholder="选择日期" size="small" style="width: 90%" type="date"
                  value-format="yyyy-MM-dd">
                <el-date-picker v-model="calibrationRecord.calibrationDate" :disabled="operationType === 'view'" format="yyyy-MM-dd" placeholder="选择日期"
                                size="small"
                                style="width: 90%" type="date" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label="下次核查日期:" label-width="140px" prop="nextCalibrationDate">
                <el-date-picker v-model="calibrationRecord.nextCalibrationDate" :disabled="operationType === 'view'"
                  :picker-options="{ disabledDate: this.disabledDate }" format="yyyy-MM-dd" placeholder="选择日期"
                  size="small" style="width: 90%" type="date" value-format="yyyy-MM-dd">
                <el-date-picker v-model="calibrationRecord.nextCalibrationDate" :disabled="operationType === 'view'" :picker-options="{ disabledDate: this.disabledDate }"
                                format="yyyy-MM-dd"
                                placeholder="选择日期"
                                size="small" style="width: 90%" type="date"
                                value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="核查器具:" prop="calculatingApparatus">
                <el-input v-model="calibrationRecord.calculatingApparatus" :disabled="operationType === 'view'"
                  size="small"></el-input>
                          size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="核查标准量程:" prop="standardRange">
                <el-input v-model="calibrationRecord.standardRange" :disabled="operationType === 'view'" size="small"
                  style="width: 90%"></el-input>
                          style="width: 90%"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label="核查标准不确定度:" label-width="140px" prop="calibrationStandardUncertainty">
                <el-input v-model="calibrationRecord.calibrationStandardUncertainty"
                  :disabled="operationType === 'view'" size="small" style="width: 90%"></el-input>
                <el-input v-model="calibrationRecord.calibrationStandardUncertainty" :disabled="operationType === 'view'" size="small"
                          style="width: 90%"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="核查指导书:" prop="byDocument">
                <el-input v-model="calibrationRecord.byDocument" :disabled="operationType === 'view'"
                  size="small"></el-input>
                          size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="检查报告编号:" prop="certificateSerialNumber">
                <el-input v-model="calibrationRecord.certificateSerialNumber" :disabled="operationType === 'view'"
                  size="small" style="width: 90%"></el-input>
                <el-input v-model="calibrationRecord.certificateSerialNumber" :disabled="operationType === 'view'" size="small"
                          style="width: 90%"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
@@ -171,16 +176,17 @@
            </el-col>
            <el-col :span="23">
              <el-form-item label="附件:" prop="fileName">
                <el-input v-model="calibrationRecord.fileName"
                  :style="`width: ${operationType === 'add' ? '90%' : '100%'};}`" disabled size="small">
                <el-input v-model="calibrationRecord.fileName" :style="`width: ${operationType === 'add' ? '90%' : '100%'};}`" disabled
                          size="small">
                  <el-button v-if="operationType === 'add'" slot="append" icon="el-icon-delete-solid"
                    @click="deleteFile"></el-button>
                             @click="deleteFile"></el-button>
                </el-input>
                <el-upload v-if="operationType === 'add'" ref="upload" :action="action" :before-upload="beforeUpload"
                  :headers="uploadHeader" :limit="1" :on-error="onError" :on-success="handleSuccessUp"
                  :show-file-list="false" style="float: right;">
                <el-upload v-if="operationType === 'add'" ref="upload" :action="action" :before-upload="beforeUpload" :headers="uploadHeader"
                           :limit="1" :on-error="onError" :on-success="handleSuccessUp"
                           :show-file-list="false"
                           style="float: right;">
                  <el-button :loading="upLoading" size="small" style="position: relative; top: -4px;"
                    type="primary">附件上传
                             type="primary">附件上传
                  </el-button>
                </el-upload>
              </el-form-item>
@@ -188,7 +194,7 @@
            <el-col :span="24">
              <el-form-item label="备注:">
                <el-input v-model="calibrationRecord.remark" :disabled="operationType === 'view'" :rows="3" size="small"
                  style="width: 96%" type="textarea"></el-input>
                          style="width: 96%" type="textarea"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
@@ -229,13 +235,12 @@
          </el-table-column>
          <el-table-column label="单项结果说明" prop="singleResultStatement">
            <template slot-scope="scope">
              <el-input v-model="scope.row.singleResultStatement" :disabled="operationType === 'view'"
                size="small"></el-input>
              <el-input v-model="scope.row.singleResultStatement" :disabled="operationType === 'view'" size="small"></el-input>
            </template>
          </el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer" style="float: right;margin-top: 10px">
          <el-button v-if="operationType === 'add'" @click="dialogVisible1 = false">取 消</el-button>
          <el-button v-if="operationType === 'add'" @click="handleClose">取 消</el-button>
          <el-button v-if="operationType === 'add'" type="primary" @click="addRecord">确 定</el-button>
        </span>
      </div>
@@ -247,6 +252,13 @@
<script>
import file from '@/utils/file';
import { mapGetters } from "vuex";
import {
  addOrUpdateDeviceMetricRecord, deleteCNASFile, deleteDeviceMetricRecord, deleteDeviceMetrics,
  deviceMetricRecordExport,
  deviceMetricRecordPage,
  saveOrUpdateDeviceMetric,
  selectDeviceMetric, showDeviceMetricsCopy
} from "@/api/cnas/resourceDemand/device";
export default {
  components: {},
  props: {
@@ -330,7 +342,7 @@
  computed: {
    ...mapGetters(["nickName"]),
    action() {
      return this.javaApi + this.$api.personnel.saveCNASFile
      return this.javaApi + '/personBasicInfo/saveCNASFile'
    }
  },
  mounted() {
@@ -369,7 +381,7 @@
    async getXmsg() {
      this.calibrateParamsLoading = true
      try {
        await this.$axios.get(this.$api.deviceCheck.selectDeviceMetric + "?deviceId=" + this.clickNodeVal.value + "&type=examine").then(res => {
        await selectDeviceMetric({deviceId: this.clickNodeVal.value, type: 'examine'}).then(res => {
          if (res.code == 200) {
            this.calibrateParams = res.data
          }
@@ -393,11 +405,7 @@
          this.form0.deviceId = this.clickNodeVal.value;
          this.form0.createdBy = this.nickName;
          this.form0.type = 'examine'
          this.$axios.post(this.$api.deviceCheck.saveOrUpdateDeviceMetric, this.form0, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
          saveOrUpdateDeviceMetric(this.form0).then(res => {
            if (res.code == 200) {
              this.$message.success('保存成功')
              this.$refs['form0'].resetFields()
@@ -414,7 +422,7 @@
    },
    // 查询设备核查列表
    getTableList(deviceId) {
      this.$axios.get(this.$api.deviceCheck.deviceMetricRecordPage + '?deviceId=' + deviceId + "&size=" + this.search.size + "&current=" + this.search.current + "&type=examine").then(res => {
      deviceMetricRecordPage({deviceId: deviceId, size: this.search.size, current: this.search.current, type: 'examine'}).then(res => {
        this.tableData = res.data.records
        this.search.total = res.data.total
      })
@@ -436,12 +444,11 @@
            this.calibrationRecord.deviceId = this.clickNodeVal.value;
            this.calibrationRecord.createUser = this.nickName
            this.calibrationRecord.deviceMetricsCopyList = this.calibrateParams
            this.calibrationRecord.deviceMetricsCopyList.forEach(ele => {
              delete ele.creationTime
            })
            this.calibrationRecord.type = 'examine'
            this.$axios.post(this.$api.deviceCheck.addOrUpdateDeviceMetricRecord, this.calibrationRecord, {
              headers: {
                'Content-Type': 'application/json'
              }
            }).then(res => {
            addOrUpdateDeviceMetricRecord(this.calibrationRecord).then(res => {
              if (res.code == 200) {
                this.$message.success('添加成功')
                this.dialogVisible1 = false
@@ -457,6 +464,22 @@
          this.$message.warning('有必填项未填');
        }
      })
    },
    handleClose(done) {
      this. calibrationRecord = {
        unitOfMeasure: '', // 核查人
        calibrationDate: '', // 核查日期
        nextCalibrationDate: '', // 下次核查日期
        calculatingApparatus: '', // 核查器具
        standardRange: '', // 核查标准量程
        calibrationStandardUncertainty: '', // 核查标准不确定度
        byDocument: '', // 核查指导书
        certificateSerialNumber: '', // 检查报告指导书
        fileName: '', // 附件
        status: '', // 核查总结论
        remark: '', // 备注
      }
      this.dialogVisible1 = false
    },
    resetcalibrationRecord() {
      this.$refs.calibrationRecord.resetFields()
@@ -492,7 +515,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.personnel.deleteCNASFile + "?fileName=" + this.form.systemFileName).then(res => {
        deleteCNASFile({fileName: this.form.systemFileName}).then(res => {
          if (res.code == 200) {
            this.$message.success('删除成功!')
          }
@@ -506,10 +529,7 @@
    },
    // end
    handleAttachmentClick(row) {
      // 模拟下载附件
      const imageUrl = this.javaApi + '/img/' + row.systemFileName; // 图片 URL
      file.downloadIamge(imageUrl, row.fileName)
      // downloadImage(imageUrl, row.fileName);
      this.$download.saveAs(row.systemFileName, row.fileName)
    },
    // 添加核查记录
    add(type) {
@@ -519,7 +539,7 @@
    },
    // 查看详情
    handleViewClick(type, row) {
      this.$axios.get(this.$api.deviceCheck.showDeviceMetricsCopy + "?id=" + row.id + "&type=examine").then(res => {
      showDeviceMetricsCopy({id: row.id, type: 'examine'}).then(res => {
        this.calibrateParams = res.data
      })
      this.calibrationRecord = { ...row }
@@ -534,7 +554,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.deviceCheck.deleteDeviceMetricRecord + "?id=" + row.id).then(res => {
        deleteDeviceMetricRecord({id: row.id}).then(res => {
          this.getTableList(this.clickNodeVal.value) // 获取设备校准列表数据
          this.$message.success('删除成功!')
        })
@@ -551,7 +571,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.deviceCheck.deleteDeviceMetrics + "?id=" + row.id).then(res => {
        deleteDeviceMetrics({id: row.id}).then(res => {
          this.getXmsg();
          this.$message.success('删除成功!')
        })
@@ -561,7 +581,15 @@
          message: '已取消删除'
        });
      })
    }
    },
    downLoadPost() {
      this.outLoading = true
      deviceMetricRecordExport({deviceId: this.clickNodeVal.value}).then(res => {
        this.outLoading = false
        const blob = new Blob([res],{ type: 'application/msword' });
        this.$download.saveAs(blob, '设备核查.xlsx')
      })
    },
  },
  watch: {
    // 监听点击el-tree的数据,进行数据刷新
@@ -622,6 +650,7 @@
.btns {
  text-align: right;
  margin-top: 10px;
}
h4 {