Crunchy
2025-03-17 0a26d58a3906b9e13946c7cb46fae51a0de98920
src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/power-supply-stability.vue
@@ -6,10 +6,8 @@
        <el-button size="small" type="primary" @click="openAddDia">新 增</el-button>
      </div>
    </div>
    <el-table
      :data="tableData"
      height="calc(100vh - 18em)"
      style="width: 100%">
    <el-table :data="tableData" height="calc(100vh - 18em)" style="width: 100%"
              :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>
@@ -33,50 +31,35 @@
        </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"
    <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]" :total="search.total"
                   background layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
                   @current-change="handleCurrentChange">
    </el-pagination>
    <el-dialog
      :visible.sync="dialogVisible"
      title="新增"
      width="50%"
      @open="openDialog">
    <el-dialog :visible.sync="dialogVisible" title="新增" width="50%" @open="openDialog">
      <div style="height: 50vh; overflow-y: auto">
        <el-form ref="form" :model="form" label-width="120px">
          <el-row>
            <el-col :span="12">
              <el-form-item :rules="[{ required: true, message: '请输入测试地点', trigger: 'blur' }]" label="测试地点"
                            prop="testLocation">
                prop="testLocation">
                <el-input v-model="form.testLocation" size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :rules="[{ required: true, message: '请输入测试日期', trigger: 'change' }]" label="测试日期"
                            prop="testDate">
                <el-date-picker
                  v-model="form.testDate"
                  format="yyyy-MM-dd"
                  placeholder="选择日期"
                  size="small"
                  style="width: 100%"
                  type="date"
                  value-format="yyyy-MM-dd">
                prop="testDate">
                <el-date-picker v-model="form.testDate" format="yyyy-MM-dd" placeholder="选择日期" size="small"
                  style="width: 100%" type="date" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :rules="[{ required: true, message: '请输入设备名称', trigger: 'change' }]" label="设备名称"
                            prop="deviceId">
                <el-select v-model="form.deviceId"
                           class="table_input"
                           clearable
                           filterable
                           placeholder="设备名称"
                           size="small" @change="getCalibrationDateFun">
                  <el-option v-for="item in equipOptions" :key="item.id"  :label="item.deviceName" :value="item.id">
                    {{item.deviceName + item.managementNumber}}
                prop="deviceId">
                <el-select v-model="form.deviceId" class="table_input" clearable filterable placeholder="设备名称"
                  size="small" @change="getCalibrationDateFun">
                  <el-option v-for="item in equipOptions" :key="item.id" :label="item.deviceName" :value="item.id">
                    {{ item.deviceName + item.managementNumber }}
                  </el-option>
                </el-select>
              </el-form-item>
@@ -98,8 +81,8 @@
            </el-col>
            <el-col :span="12">
              <el-form-item label="检测者" prop="recipientUser">
                <el-select v-model="form.testerId" clearable filterable placeholder="请选择"
                           size="small" style="width: 100%;">
                <el-select v-model="form.testerId" clearable filterable placeholder="请选择" size="small"
                  style="width: 100%;">
                  <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
@@ -107,8 +90,8 @@
            </el-col>
            <el-col :span="12">
              <el-form-item label="核查人" prop="recipientUser">
                <el-select v-model="form.checkerId" clearable filterable placeholder="请选择"
                           size="small" style="width: 100%;" >
                <el-select v-model="form.checkerId" clearable filterable placeholder="请选择" size="small"
                  style="width: 100%;">
                  <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
                  </el-option>
                </el-select>
@@ -116,11 +99,7 @@
            </el-col>
            <el-col :span="24">
              <el-form-item label="结论">
                <el-input
                  v-model="form.conclusion"
                  :rows="2"
                  placeholder="请输入内容"
                  type="textarea">
                <el-input v-model="form.conclusion" :rows="2" placeholder="请输入内容" type="textarea">
                </el-input>
              </el-form-item>
            </el-col>
@@ -130,25 +109,15 @@
              <el-button size="small" type="primary" @click="feMeasuredQuantityListAdd">新增</el-button>
            </div>
            <div>
              <el-table
                :data="form.feMeasuredQuantityList"
                height="40vh"
                style="width: 100%; margin: auto">
              <el-table :data="form.feMeasuredQuantityList" height="40vh" style="width: 100%; margin: auto"
                        :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
                <el-table-column label="序号" type="index" width="80"></el-table-column>
                <el-table-column
                  align="center"
                  label="测定量名称"
                  min-width="180"
                  prop="measuredQuantityLabel">
                <el-table-column align="center" label="测定量名称" min-width="180" prop="measuredQuantityLabel">
                  <template #default="{ row }">
                    <el-input v-model="row.measuredQuantityLabel" :rows="1" type="textarea"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  align="center"
                  label="值"
                  min-width="300"
                  prop="name">
                <el-table-column align="center" label="值" min-width="300" prop="name">
                  <template>
                    <el-table-column align="center" label="A" min-width="100" prop="valueA">
                      <template #default="{ row }">
@@ -167,10 +136,7 @@
                    </el-table-column>
                  </template>
                </el-table-column>
                <el-table-column
                  fixed="right"
                  label="操作"
                  width="100">
                <el-table-column fixed="right" label="操作" width="100">
                  <template slot-scope="scope">
                    <el-button size="small" type="text" @click="feMeasuredQuantityListDelete(scope.row, scope.$index)">
                      删除
@@ -191,11 +157,23 @@
</template>
<script>
import {
  getLaboratoryFacilityPowerStablePage,
  deviceScopeSearch,
  treeDevice,
  selectUserCondition,
  addLaboratoryFacilityPowerStable,
  deleteFeMeasuredQuantity,
  getFeMeasuredQuantityService,
  deleteLaboratoryFacilityPowerStable,
  exportFePowerStable
} from '@/api/cnas/resourceDemand/facilitiesEnvironment/facilitiesAndEnvironment'
export default {
  data() {
    return {
      search: {
        size: 20,
        size: 10,
        current: 1,
        total: 0
      },
@@ -235,11 +213,14 @@
  methods: {
    // 初始化调用
    initData() {
      this.$axios.get(this.$api.facilitiesAndEnvironment.getLaboratoryFacilityPowerStablePage + '?size=' + this.search.size + '&current=' + this.search.current).then(res => {
        if (res.code === 201) return;
        this.tableData = res.data.records;
        this.search.total = res.data.total;
      });
      getLaboratoryFacilityPowerStablePage({
        ...this.search
      }).then(res => {
        if (res.code === 200) {
          this.tableData = res.data.records;
          this.search.total = res.data.total;
        }
      })
    },
    handleSizeChange(val) {
      this.search.size = val;
@@ -256,20 +237,20 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.facilitiesAndEnvironment.deleteLaboratoryFacilityPowerStable + '?powerStableId=' + row.powerStableId).then(res => {
        deleteLaboratoryFacilityPowerStable({ powerStableId: row.powerStableId }).then(res => {
          this.$message.success('删除成功!')
          this.initData()
        })
      })
    },
    openAddDia () {
    openAddDia() {
      this.dialogVisible = true
      this.getEquipOptions()
    },
    // 获取所有设备
    getEquipOptions() {
      this.equipOptions = []
      this.$axios.get(this.$api.deviceScope.deviceScopeSearch+'?status=0').then(res => {
      deviceScopeSearch({ status: '0' }).then(res => {
        if (res.code === 200 && res.data) {
          this.equipOptions = res.data
        }
@@ -279,9 +260,9 @@
    },
    // 电源稳定性-打开弹框调用设备接口,查询使用的设备
    openDialog() {
      this.$axios.get(this.$api.deviceScope.treeDevice).then(res => {
      treeDevice().then(res => {
        this.cascaderList = res.data;
      });
      })
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
@@ -299,8 +280,7 @@
    // 电源稳定性-测定量弹框中表格的删除行
    feMeasuredQuantityListDelete(row, index) {
      if (row.measuredQuantityId) {
        this.$axios.delete(this.$api.facilitiesAndEnvironment.deleteFeMeasuredQuantity + '?measuredQuantityId=' + row.measuredQuantityId).then(res => {
          if (res.code === 201) return
        deleteFeMeasuredQuantity({ measuredQuantityId: row.measuredQuantityId }).then(res => {
          this.form.feMeasuredQuantityList.splice(index, 1)
          this.$message.success('删除成功!')
        })
@@ -324,11 +304,7 @@
      this.submitLoading = true
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$axios.post(this.$api.facilitiesAndEnvironment.addLaboratoryFacilityPowerStable, this.form, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
          addLaboratoryFacilityPowerStable(this.form).then(res => {
            this.submitLoading = false
            if (res.code === 200) {
              this.initData()
@@ -342,50 +318,32 @@
    },
    // 导出
    downLoadPost(row) {
      this.$axios.get(this.$api.facilitiesAndEnvironment.exportFePowerStable + '?powerStableId=' + row.powerStableId,{responseType: "blob"}).then(res => {
      exportFePowerStable({ powerStableId: row.powerStableId }).then(res => {
        this.outLoading = false
        const blob = new Blob([res],{ type: 'application/msword' });
        //将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 = '电源稳定性' + '.docx';
              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 = '电源稳定性' + '.docx';
            link.click();
            this.$message.success('导出成功')
          }
        }
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, '电源稳定性.docx')
      })
    },
    // 电源稳定性 点击行编辑触发
    edit(row) {
      this.$axios.get(this.$api.facilitiesAndEnvironment.getFeMeasuredQuantityService + "?powerStableId=" + row.powerStableId).then(res => {
        this.form = {...row}
      getFeMeasuredQuantityService({ powerStableId: row.powerStableId }).then((res => {
        this.form = { ...row }
        this.form.feMeasuredQuantityList = res.data;
        this.dialogVisible = true
      });
      }))
    },
    // 获取负责人信息接口
    getUserList() {
      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
      selectUserCondition().then(res => {
        if (res.code == 200) {
          this.responsibleOptions = res.data
          let data = []
          res.data.forEach(a => {
            data.push({
              id: a.id,
              name: a.name
            })
          })
          this.responsibleOptions = data
        }
      })
    },