spring
2025-03-03 f01d916828cf9746a0f438d9472af9271efd9729
src/views/CNAS/resourceDemand/device/component/state.vue
@@ -237,7 +237,17 @@
  </div>
</template>
<script>
import {
  saveDeviceState,
  selectDeviceByCode,
  exportDeviceStatus,
  deleteDeviceState,
  deviceStateExport,
  getDeviceStatePage,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/business/inspectionTask";
import { dateFormat } from '@/utils/date'
import { mapGetters } from "vuex";
export default {
  props: {
    clickNodeVal: {
@@ -246,6 +256,9 @@
        return {};
      }
    }
  },
  computed: {
    ...mapGetters(["nickName"]),
  },
  data() {
    return {
@@ -311,25 +324,24 @@
      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.createUser = user.name
              this.form.submitOperatingPersonnel = user.name
              this.form.createUser = this.nickName
              this.form.submitOperatingPersonnel = this.nickName
              this.form.submitDate = dateTime
              break
            case 1:
              this.form.departmentOperatingPersonnel = user.name
              this.form.departmentOperatingPersonnel = this.nickName
              this.form.departmentDate = dateTime
              break
            case 2:
              this.form.measuringRoomOperatingPersonnel = user.name
              this.form.measuringRoomOperatingPersonnel = this.nickName
              this.form.measuringRoomDate = dateTime
              break
            case 3:
              this.form.approvalOperatingPersonnel = user.name
              this.form.approvalOperatingPersonnel = this.nickName
              this.form.approvalDate = dateTime
              break
            default:
@@ -355,11 +367,7 @@
          // 获取当前状态
          this.form.currentState = currentStepAction === 4 ? '关闭' : this.steps[currentStepAction]
          this.form.deviceId = this.clickNodeVal.value
          this.$axios.post(this.$api.deviceCheck.saveDeviceState, this.form, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
          saveDeviceState(this.form).then(res => {
            if (res.code == 200) {
              this.$message.success('提交成功')
              this.getDeviceStatePage(this.clickNodeVal.value)
@@ -385,7 +393,7 @@
    },
    openRecordAcceptance() {
      // 获取设备基础信息
      this.$axios.get(this.$api.deviceScope.selectDeviceByCode + '?id=' + this.clickNodeVal.value).then(res => {
      selectDeviceByCode({ id: this.clickNodeVal.value }).then(res => {
        this.form.deviceName = res.data.deviceName
        this.form.specificationModel = res.data.specificationModel
        this.form.managementNumber = res.data.managementNumber
@@ -398,7 +406,7 @@
    },
    // 获取负责人信息接口
    getUserList() {
      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
      selectUserCondition().then(res => {
        if (res.code == 200) {
          this.responsibleOptions = res.data
        }
@@ -418,37 +426,11 @@
    // 导出
    handleDownOne(row) {
      this.outLoading = true
      this.$axios.get(this.$api.deviceCheck.exportDeviceStatus + '?deviceId=' + row.deviceId + '&processNumber=' + row.processNumber, {
        responseType: "blob"
      }).then(res => {
      exportDeviceStatus({ deviceId: row.deviceId, processNumber: row.processNumber }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        //将Blob 对象转换成字符串
        let reader = new FileReader();
        reader.readAsText(blob, 'utf-8');
        reader.onload = () => {
          try {
            let result = JSON.parse(reader.result);
            if (result.message) {
              this.$message.error(result.message);
            } else {
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              link.download = '设备停/启用.doc';
              link.click();
              this.$message.success('导出成功')
            }
          } catch (err) {
            console.log(err);
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = '设备停/启用.doc';
            link.click();
            this.$message.success('导出成功')
          }
        }
        this.$download.saveAs(blob, '设备停/启用.doc')
        this.$message.success('导出成功')
      })
    },
    // 删除
@@ -458,7 +440,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.deviceCheck.deleteDeviceState + '?stateId=' + row.stateId).then(res => {
        deleteDeviceState({ stateId: row.stateId }).then(res => {
          if (res.code == 200) {
            this.$message.success('删除成功')
            this.getDeviceStatePage(this.clickNodeVal.value)
@@ -470,43 +452,18 @@
          message: '已取消删除'
        });
      });
    },
    //导出
    handleDown() {
      this.outLoading = true
      this.$axios.post(this.$api.deviceCheck.deviceStateExport, {
      deviceStateExport({
        deviceId: this.clickNodeVal.value,
        processNumber: this.search.processNumber
      }, { responseType: "blob" }).then(res => {
      }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], { type: 'application/octet-stream' });
        //将Blob 对象转换成字符串
        let reader = new FileReader();
        reader.readAsText(blob, 'utf-8');
        reader.onload = () => {
          try {
            let result = JSON.parse(reader.result);
            if (result.message) {
              this.$message.error(result.message);
            } else {
              const url = URL.createObjectURL(blob);
              const link = document.createElement('a');
              link.href = url;
              link.download = '设备停用/启用.xlsx';
              link.click();
              this.$message.success('导出成功')
            }
          } catch (err) {
            console.log(err);
            const url = URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = url;
            link.download = '设备停用/启用.xlsx';
            link.click();
            this.$message.success('导出成功')
          }
        }
        this.$download.saveAs(blob, '设备停用/启用.xlsx')
        this.$message.success('导出成功')
      }).finally(() => {
        this.outLoading = false
      })
@@ -521,7 +478,7 @@
      this.getDeviceStatePage(this.clickNodeVal.value);
    },
    getDeviceStatePage(deviceId) {
      this.$axios.get(this.$api.deviceCheck.getDeviceStatePage + '?deviceId=' + deviceId + "&size=" + this.search.size + "&current=" + this.search.current + "&processNumber=" + this.search.processNumber).then(res => {
      getDeviceStatePage({ deviceId, ...this.search }).then(res => {
        if (res.code == 200) {
          this.tableDatalist = res.data.records
          this.search.total = res.data.total