Crunchy
2025-04-29 e5454b769d44a34af423bf87ac8a740bf8c20341
src/views/CNAS/resourceDemand/device/component/calibration.vue
@@ -4,10 +4,10 @@
    <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" @click="handleDown">导出Excel</el-button>
      <!-- <el-button size="small" type="primary" @click="handleDown">导出Excel</el-button> -->
    </div>
    <div class="tables" style="margin-top: 10px;">
      <el-table :data="tableData" height="calc(100vh - 20em)">
      <el-table :data="tableData" height="calc(100vh - 20em)" :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
        <el-table-column label="序号" type="index" width="120">
          <template v-slot="scope">
            <span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
@@ -36,8 +36,8 @@
        </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" style="margin-right: 5%;"
        @size-change="handleSizeChange" @current-change="handleCurrentChange">
        :total="search.total" layout="->,total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange" @current-change="handleCurrentChange" background>
      </el-pagination>
    </div>
    <!-- 校准项目维护 -->
@@ -78,6 +78,7 @@
      </h4>
      <!-- 设备校准参数表格 -->
      <el-table ref="calibrateTable" v-loading="calibrateParamsLoading" :data="calibrateParams" max-height="450" stripe
                :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
        style="width: 100%">
        <el-table-column label="编号" type="index" width="80"></el-table-column>
        <el-table-column label="计量参数" prop="measurementParameter"></el-table-column>
@@ -204,7 +205,7 @@
            <span class="line"></span><span>校准条目确认结果</span>
          </span>
        </h4>
        <el-table ref="calibrateTable" :data="calibrateParams" border>
        <el-table ref="calibrateTable" :data="calibrateParams" :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
          <el-table-column label="编号" type="index" width="60"></el-table-column>
          <el-table-column label="计量参数" prop="measurementParameter"></el-table-column>
          <el-table-column label="量程范围" prop="rangeOfMeasurement"></el-table-column>
@@ -240,20 +241,6 @@
            </template>
          </el-table-column>
        </el-table>
        <!-- 操作日志 -->
        <!--        <h4>-->
        <!--          <div style="display: flex;-->
        <!--      align-items: center;">-->
        <!--            <span class="line"></span><span>本记录状态和操作日志</span>-->
        <!--          </div>-->
        <!--        </h4>-->
        <!--        <el-table :data="tableDataOperate" style="width: 100%">-->
        <!--          <el-table-column type="index" label="序号" width="100"></el-table-column>-->
        <!--          <el-table-column prop="operator" label="操作人" width="120"></el-table-column>-->
        <!--          <el-table-column prop="operationTime" label="操作时间" width="180"></el-table-column>-->
        <!--          <el-table-column prop="operationType" label="操作类型" width="120"></el-table-column>-->
        <!--          <el-table-column prop="operationContent" label="操作内容"></el-table-column>-->
        <!--        </el-table>-->
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button v-if="operationType === 'add'" @click="dialogVisible1 = false">取 消</el-button>
@@ -265,10 +252,8 @@
</template>
<script>
import fileDownload from "@/utils/file";
import {
  deviceMetricRecordPage,
  deviceLog,
  showDeviceMetricsCopy,
  deleteDeviceMetricRecord,
  deviceMetricRecordExport,
@@ -276,7 +261,9 @@
  selectDeviceMetric,
  deleteDeviceMetrics,
  addOrUpdateDeviceMetricRecord,
  saveOrUpdateDeviceMetric
} from '@/api/cnas/resourceDemand/device.js'
import { mapGetters } from "vuex";
export default {
  props: {
    clickNodeVal: {
@@ -343,7 +330,6 @@
        ],
      },
      addRecordLoading: false,
      tableDataOperate: [], // 本记录状态和操作日志
      upLoading: false,
      operationType: '',
      search: {
@@ -355,13 +341,13 @@
  },
  // 用于上传文件的信息
  computed: {
    ...mapGetters(["nickName"]),
    action() {
      return this.javaApi + '/personBasicInfo/saveCNASFile'
    }
  },
  mounted() {
    //获取操作记录信息
    this.getOperateMsg();
    this.getTableList(this.clickNodeVal.value) // 获取设备校准列表数据
  },
  methods: {
@@ -397,11 +383,6 @@
        this.search.total = res.data.total
      })
    },
    getOperateMsg() {
      deviceLog(this.clickNodeVal.value).then(res => {
        this.tableDataOperate = res.data
      })
    },
    // 添加核查记录
    add(type) {
      this.operationType = type
@@ -410,7 +391,7 @@
    },
    // 查看详情
    handleViewClick(type, row) {
      showDeviceMetricsCopy({ id: row.id, type: calibrate }).then(res => {
      showDeviceMetricsCopy({ id: row.id, type: 'calibrate' }).then(res => {
        this.calibrateParams = res.data
      })
      this.calibrationRecord = { ...row }
@@ -436,30 +417,18 @@
      })
    },
    handleAttachmentClick(row) {
      let state = /\.(jpg|jpeg|png|gif)$/i.test(row.systemFileName)
      if (state) {
        let url = this.javaApi + '/img/' + row.systemFileName;
        fileDownload.downloadIamge(url, row.systemFileName)
      } else {
        const url = this.javaApi + '/word/' + row.systemFileName
        const link = document.createElement('a');
        link.href = url;
        link.download = row.systemFileName;
        link.click();
        this.$message.success('下载成功')
      }
      this.$download.saveAs(row.systemFileName, row.systemFileName)
    },
    //导出
    handleDown() {
      this.outLoading = true
      deviceMetricRecordExport({
        deviceId: this.clickNodeVal.value,
        type: calibrate
        type: 'calibrate'
      }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        this.$download.saveAs(blob, '设备校准.xlsx')
        this.$message.success('导出成功')
      })
    },
    deleteFile() {
@@ -527,10 +496,9 @@
          this.calibrateParamsLoading = true
          this.addCalibrateLoading = true
          this.form0.deviceId = this.clickNodeVal.value;
          const user = JSON.parse(localStorage.getItem('user'))
          this.form0.createdBy = user.name;
          this.form0.createdBy = this.nickName;
          this.form0.type = 'calibrate'
          deleteDeviceMetrics(this.form0).then(res => {
          saveOrUpdateDeviceMetric(this.form0).then(res => {
            if (res.code == 200) {
              this.$message.success('保存成功')
              this.$refs['form0'].resetFields()
@@ -559,8 +527,7 @@
            }
            this.addRecordLoading = true
            this.calibrationRecord.deviceId = this.clickNodeVal.value;
            let user = JSON.parse(localStorage.getItem('user'))
            this.calibrationRecord.createUser = user.name
            this.calibrationRecord.createUser = this.nickName
            this.calibrationRecord.type = 'calibrate'
            this.calibrationRecord.deviceMetricsCopyList = this.calibrateParams
            addOrUpdateDeviceMetricRecord(this.calibrationRecord).then(res => {
@@ -636,16 +603,6 @@
      }
    }
  }
}
function downloadImage(url) {
  const link = document.createElement('a');
  link.href = url;
  link.target = "_blank"
  link.download = 'attachment.jpg'; // 文件名
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}
</script>