zhuo
2025-03-31 46add839980507f30a87d62599671b88fdc86145
src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/temperature-humidity-record.vue
@@ -4,19 +4,21 @@
      <el-col :span="12">
        <div class="header">
          <div>试验区域</div>
          <div>
            名称:
            <el-input v-model="search.testAreaName" clearable size="small" style="width: 120px"></el-input>
            <el-button size="small" type="primary" @click="initData">查询</el-button>
            <el-button size="small" type="primary" @click="clickAdd">新 增</el-button>
          <div style="display: flex;">
            <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
              <span style="width: 48px;font-size: 14px;font-weight: 700;color: #606266;">名称</span>
              <el-input size="small" placeholder="请输入" clearable v-model="search.testAreaName"
                        @keyup.enter.native="initData"></el-input>
            </div>
            <div style="line-height: 30px;">
              <el-button size="mini" type="primary" @click="initData">查询</el-button>
              <el-button size="mini" type="primary" @click="clickAdd">新 增</el-button>
            </div>
          </div>
        </div>
        <el-table
            :data="tableData"
            height="calc(100vh - 18em)"
            highlight-current-row
            style="width: 100%"
            @row-click="clickRow">
        <el-table :data="tableData" height="calc(100vh - 18em)" highlight-current-row style="width: 100%"
                  :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
          @row-click="clickRow">
          <el-table-column label="序号" type="index" width="60" align="center"></el-table-column>
          <el-table-column label="月度时间" min-width="180" prop="monthDate"></el-table-column>
          <el-table-column label="试验区域名称" min-width="180" prop="testAreaName"></el-table-column>
@@ -30,34 +32,34 @@
          <el-table-column fixed="right" label="操作" min-width="180" align="center">
            <template v-slot="scope">
              <el-button size="small" type="text" @click="downLoadPost(scope.row)">导出</el-button>
              <el-button size="small" type="text" @click="edit(scope.row)">编辑</el-button>
              <el-button :disabled="scope.row.isAffirm === '1'" size="small" type="text" @click="openApprovalDialog(scope.row)">确认</el-button>
<!--              <el-button size="small" type="text" @click="edit(scope.row)">编辑</el-button>-->
              <el-button :disabled="scope.row.isAffirm === '1'" size="small" type="text"
                @click="openApprovalDialog(scope.row)">确认</el-button>
              <el-button size="small" type="text" @click="deleteRowFun(scope.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 :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]" background
          :total="search.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
          @current-change="handleCurrentChange">
        </el-pagination>
      </el-col>
      <el-col :span="12">
        <div class="header">
          <div>温湿度记录:{{ saveRow.monthDate }}</div>
          <div>
            <el-button v-if="saveRow.monthDate" size="small" type="primary" @click="dialogVisible1 = true">新 增</el-button>
            <el-button v-if="saveRow.monthDate" size="small" type="primary" @click="dialogVisible1 = true">新
              增</el-button>
          </div>
        </div>
        <el-table
            :data="tableData1"
            height="calc(100vh - 18em)"
            style="width: 100%">
        <el-table :data="tableData1" height="calc(100vh - 18em)" style="width: 100%"
                  :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border>
          <el-table-column label="序号" type="index" width="60" align="center"></el-table-column>
          <el-table-column label="日期" min-width="100" prop="recordDate"></el-table-column>
          <el-table-column align="center" label="上午" min-width="200">
            <template>
              <el-table-column label="时间" min-width="110" prop="morningTestTime" show-overflow-tooltip></el-table-column>
              <el-table-column label="时间" min-width="110" prop="morningTestTime"
                show-overflow-tooltip></el-table-column>
              <el-table-column label="温度" min-width="80" prop="morningTemp" show-overflow-tooltip></el-table-column>
              <el-table-column label="湿度" min-width="80" prop="morningHum" show-overflow-tooltip></el-table-column>
            </template>
@@ -79,37 +81,27 @@
            </template>
          </el-table-column>
        </el-table>
        <el-pagination :current-page="1" :page-size="search1.size" :page-sizes="[10, 20, 30, 50, 100]"
                       :total="search1.total" layout="->,total, sizes, prev, pager, next, jumper"
                       @size-change="handleSizeChange1"
                       @current-change="handleCurrentChange1">
        <el-pagination :current-page="1" :page-size="search1.size" :page-sizes="[10, 20, 30, 50, 100]" background
          :total="search1.total" layout="->,total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange1"
          @current-change="handleCurrentChange1">
        </el-pagination>
      </el-col>
    </el-row>
    <el-dialog
        :visible.sync="dialogVisible"
        title="提示"
        width="50%">
    <el-dialog :visible.sync="dialogVisible" title="提示" width="50%">
      <div style="height: 20vh;">
        <el-form ref="form" :model="form" label-width="80px">
          <el-row>
            <el-col :span="24">
              <el-form-item :rules="[{ required: true, message: '请输入月度时间', trigger: 'blur' }]" label="月度时间"
                            prop="monthDate">
                <el-date-picker
                    v-model="form.monthDate"
                    format="yyyy-MM"
                    placeholder="选择月份"
                    size="small"
                    style="width: 100%"
                    type="month"
                    value-format="yyyy-MM">
                prop="monthDate">
                <el-date-picker v-model="form.monthDate" format="yyyy-MM" placeholder="选择月份" size="small"
                  style="width: 100%" type="month" value-format="yyyy-MM">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :rules="[{ required: true, message: '请输入试验区域', trigger: 'blur' }]" label="试验区域"
                            prop="testAreaName">
                prop="testAreaName">
                <el-input v-model="form.testAreaName"></el-input>
              </el-form-item>
            </el-col>
@@ -117,40 +109,25 @@
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" :loading="submitLoading" @click="addPowerSupplyStability">确 定</el-button>
  </span>
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="addPowerSupplyStability">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
        :visible.sync="dialogVisible1"
        title="提示"
        width="50%"
        @open="openDialog">
    <el-dialog :visible.sync="dialogVisible1" title="提示" width="50%" @open="openDialog">
      <div style="height: 40vh;">
        <el-form ref="form1" :model="form1" label-width="120px">
          <el-row>
            <el-col :span="24">
              <el-form-item label="日期">
                <el-date-picker
                  v-model="form1.recordDate"
                  format="yyyy-MM-dd"
                  placeholder="请选择日期"
                  size="small"
                  style="width: 50%"
                  type="date"
                  value-format="yyyy-MM-dd">
                <el-date-picker v-model="form1.recordDate" format="yyyy-MM-dd" placeholder="请选择日期" size="small"
                  style="width: 50%" type="date" value-format="yyyy-MM-dd">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="上午时间">
                <el-time-picker
                  v-model="form1.morningTestTime"
                  size="small"
                  value-format="HH:mm:ss"
                  format="HH:mm:ss"
                  style="width: 100%"
                  placeholder="请选择时间">
                <el-time-picker v-model="form1.morningTestTime" size="small" value-format="HH:mm:ss" format="HH:mm:ss"
                  style="width: 100%" placeholder="请选择时间">
                </el-time-picker>
              </el-form-item>
            </el-col>
@@ -166,8 +143,8 @@
            </el-col>
            <el-col :span="12">
              <el-form-item label="上午记录员">
                <el-select v-model="form1.morningRecorderId" clearable filterable placeholder="请选择"
                           size="small" style="width: 100%;">
                <el-select v-model="form1.morningRecorderId" 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>
@@ -175,13 +152,8 @@
            </el-col>
            <el-col :span="12">
              <el-form-item label="下午时间">
                <el-time-picker
                  v-model="form1.afternoonTime"
                  size="small"
                  value-format="HH:mm:ss"
                  format="HH:mm:ss"
                  style="width: 100%"
                  placeholder="请选择时间">
                <el-time-picker v-model="form1.afternoonTime" size="small" value-format="HH:mm:ss" format="HH:mm:ss"
                  style="width: 100%" placeholder="请选择时间">
                </el-time-picker>
              </el-form-item>
            </el-col>
@@ -197,8 +169,8 @@
            </el-col>
            <el-col :span="12">
              <el-form-item label="下午记录员">
                <el-select v-model="form1.afternoonRecorderId" clearable filterable placeholder="请选择"
                           size="small" style="width: 100%;">
                <el-select v-model="form1.afternoonRecorderId" 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>
@@ -206,11 +178,7 @@
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注">
                <el-input
                    v-model="form1.note"
                    :rows="2"
                    placeholder="请输入内容"
                    type="textarea">
                <el-input v-model="form1.note" :rows="2" placeholder="请输入内容" type="textarea">
                </el-input>
              </el-form-item>
            </el-col>
@@ -218,9 +186,9 @@
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible1 = false">取 消</el-button>
    <el-button type="primary" :loading="submitLoading" @click="addPowerSupplyStability1">确 定</el-button>
  </span>
        <el-button @click="dialogVisible1 = false">取 消</el-button>
        <el-button type="primary" :loading="submitLoading" @click="addPowerSupplyStability1">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="approvalDialog" title="确认" width="30%" @close="subjoin = ''">
      <span>
@@ -236,6 +204,18 @@
</template>
<script>
import {
  getFeTempHumDate,
  addFeTempHumDate,
  getFeTempHumRecordPage,
  addFeTempHumRecord,
  selectUserCondition,
  deleteFeTempHumRecord,
  deleteFeTempHumDate,
  exportTemperatureAndHumidityRecords,
  affirmFeTempHumDate
} from '@/api/cnas/resourceDemand/facilitiesEnvironment/facilitiesAndEnvironment'
export default {
  data() {
    return {
@@ -283,22 +263,17 @@
    }
  },
  methods: {
    openApprovalDialog (row) {
    openApprovalDialog(row) {
      this.approvalDialog = true
      this.approvalRow = row
    },
    handleApproval () {
    handleApproval() {
      this.approvalLoading = true
      const params = {
        dateId: this.approvalRow.dateId,
        subjoin: this.subjoin,
      }
      this.$axios.post(this.$api.facilitiesAndEnvironment.affirmFeTempHumDate, params, {
        headers: {
          'Content-Type': 'application/json'
        },
        noQs: true
      }).then(res => {
      affirmFeTempHumDate(params).then(res => {
        this.approvalLoading = false
        if (res.code === 200) {
          this.$message.success('确认成功!')
@@ -310,7 +285,7 @@
      })
    },
    openDialog() {
      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
      selectUserCondition().then(res => {
        if (res.code == 200) {
          this.responsibleOptions = res.data
        }
@@ -320,11 +295,7 @@
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.submitLoading = true
          this.$axios.post(this.$api.facilitiesAndEnvironment.addFeTempHumDate, this.form, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
          addFeTempHumDate(this.form).then(res => {
            if (res.code === 200) {
              this.$message.success('新增成功!')
              this.submitLoading = false
@@ -346,11 +317,7 @@
        this.submitLoading = true
        if (valid) {
          this.form1.dateId = this.saveRow.dateId
          this.$axios.post(this.$api.facilitiesAndEnvironment.addFeTempHumRecord, this.form1, {
            headers: {
              'Content-Type': 'application/json'
            }
          }).then(res => {
          addFeTempHumRecord(this.form1).then(res => {
            if (res.code === 200) {
              this.$message.success('新增成功!')
              this.submitLoading = false
@@ -365,10 +332,11 @@
    },
    clickRow(row) {
      this.saveRow = row
      this.search1.current = 1
      this.initData1(row.dateId)
    },
    edit(row) {
      this.form = {...row}
      this.form = { ...row }
      this.dialogVisible = true
    },
    deleteRowFun(row) {
@@ -377,47 +345,22 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.facilitiesAndEnvironment.deleteFeTempHumDate + '?dateId=' + row.dateId).then(res => {
        deleteFeTempHumDate({ dateId: row.dateId }).then(res => {
          this.$message.success('删除成功!')
          this.initData()
        })
      })
    },
    edit1(row) {
      this.form1 = {...row}
      this.form1 = { ...row }
      this.dialogVisible1 = true
    },
    // 导出
    downLoadPost(row) {
      this.$axios.get(this.$api.facilitiesAndEnvironment.exportTemperatureAndHumidityRecords + '?dateId=' + row.dateId,{responseType: "blob"}).then(res => {
      exportTemperatureAndHumidityRecords({ dateId: row.dateId }).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')
      })
    },
    deleteRowFun1(row) {
@@ -426,28 +369,38 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete(this.$api.facilitiesAndEnvironment.deleteFeTempHumRecord + '?tempHumId=' + row.tempHumId).then(res => {
        deleteFeTempHumRecord({ tempHumId: row.tempHumId }).then(res => {
          this.$message.success('删除成功!')
          this.initData1(this.saveRow.dateId)
        })
      })
    },
    initData() {
      this.$axios.get(this.$api.facilitiesAndEnvironment.getFeTempHumDate + '?size=' + this.search.size + '&current=' + this.search.current + '&testAreaName=' + this.search.testAreaName).then(res => {
        if (res.code === 201) return;
        this.tableData = res.data.records;
        this.search.total = res.data.total;
        if (res.data.records.length === 0) {
          this.tableData1 = []
          this.saveRow.monthDate = ''
      getFeTempHumDate({
        ...this.search,
        ...this.search
      }).then(res => {
        if (res.code === 200) {
          this.tableData = res.data.records;
          this.search.total = res.data.total;
          if (res.data.records.length === 0) {
            this.tableData1 = []
            this.saveRow.monthDate = ''
          }
        }
      });
      })
    },
    initData1(dateId) {
      this.$axios.get(this.$api.facilitiesAndEnvironment.getFeTempHumRecordPage + '?size=' + this.search1.size + '&current=' + this.search1.current + '&dateId=' + dateId).then(res => {
        if (res.code === 201) return;
        this.tableData1 = res.data.records;
        this.search1.total = res.data.total;
      let form = { dateId: dateId }
      getFeTempHumRecordPage({
        ...this.search1,
        ...form
      }).then(res => {
        if (res.code === 200) {
          this.tableData1 = res.data.records;
          this.search1.total = res.data.total;
        }
      });
    },
    handleSizeChange(val) {
@@ -460,11 +413,11 @@
    },
    handleSizeChange1(val) {
      this.search1.size = val;
      this.initData1();
      this.initData1(this.saveRow.dateId);
    },
    handleCurrentChange1(val) {
      this.search1.current = val;
      this.initData1();
      this.initData1(this.saveRow.dateId);
    },
    clickAdd() {
      this.dialogVisible = true