烟花爆竹批发企业仓库安全风险监测前端
马宇豪
2025-04-16 e46a6e287f752825a8ae5f4024769cd3fbc39a4a
src/views/firework/humiture/index.vue
@@ -1,11 +1,154 @@
<template>
  <div class="app-container">
    <!--    表格部分-->
<!--   <div style="font-weight: 600;font-size: 20px;">最近报警记录</div>-->
    <div style="margin-top: 10px">
      <el-table v-loading="loading" :data="state.tableList" :border="true">
        <el-table-column label="序号" type="index" align="center" width="80" />
        <el-table-column label="仓库" prop="storeName" align="center"  />
        <el-table-column label="库房" prop="storeroomName" align="center" />
      </el-table>
      <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.pageIndex"
          v-model:limit="queryParams.pageSize"
          @pagination="getListAll"
      />
    </div>
    <!--    卡片部分-->
    <el-scrollbar max-height="420px" style="padding-right: 10px;overflow-x: hidden;" v-if="state.dataList && state.dataList.length >0">
<!--      <el-row :gutter="20" style="margin-top: 5px;margin-left: 5px">-->
<!--        <el-col v-for="(item,index) in state.dataList" :key="index" :span="8">-->
      <div class="grid-container">
        <div v-for="(item,index) in state.dataList" :key="index" style="width: 365px;margin: 20px 30px">
          <el-card class="card-item " shadow="always">
            <div style="display: flex;flex-direction: column">
              <div style="font-size: 18px;font-weight: 700;margin-bottom: 25px">{{item.storeName}}—{{item.storeroomName}}—{{item.deviceName}}</div>
              <div style="display: flex;align-items: center;margin-bottom: 15px">
                <img src="@/assets/images/device.png" />
                <div style="display: flex;flex-direction: column">
                  <div style="display: flex;justify-content: space-between;margin-bottom: 10px;align-items: center">
                    <span>温度:{{item.temperatureValue}}℃</span>
                    <el-button type="primary" plain style="margin-left: 15px" @click="openData('温度',item)">历史数据</el-button>
                  </div>
                  <div style="display: flex;justify-content: space-between;align-items: center">
                    <span>湿度:{{item.humidityValue}}%RH</span>
                    <el-button type="primary" plain style="margin-left: 15px" @click="openData('湿度',item)">历史数据</el-button>
                  </div>
                </div>
              </div>
            </div>
          </el-card>
        </div>
      </div>
<!--        </el-col>-->
<!--      </el-row>-->
    </el-scrollbar>
    <el-empty v-else description="暂无设备数据" ></el-empty>
    <d-dialog ref="dialogRef" @getList="getListAll"></d-dialog>
  </div>
</template>
<script setup>
import {onMounted, reactive, ref, toRefs} from "vue";
import {ElMessage} from "element-plus";
import dDialog from './components/dataDialog.vue'
import {getDevice, getRoomByCompany} from "@/api/company/warehouse";
import Cookies from "js-cookie";
const dialogRef = ref(null)
const state = reactive({
  queryParams: {
    pageIndex: 1,
    pageSize: 5,
    filter: {
      companyName: ''
    }
  },
  cardQueryParams: {
    pageIndex: 1,
    pageSize: 5,
    filter: {
      companyCode : ''
    }
  },
  total: 0,
  dataList: [],
  tableList: []
});
const { queryParams,cardQueryParams, total, dataList } = toRefs(state);
const loading = ref(false);
onMounted(()=>{
  const info = JSON.parse(Cookies.get('userInfo'))
  state.queryParams.filter.companyName = info.company
  state.cardQueryParams.filter.companyCode = info.companynumber
  getListPage()
  getList()
})
const getListPage = async () => {
  loading.value = true
  const res = await getRoomByCompany(state.queryParams)
  if(res.code == 200){
    state.tableList = res.result.records
    state.total = res.result.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
const getList = async () => {
  const res = await getDevice(state.cardQueryParams)
  if(res.code == 200){
    state.dataList = res.result
  }else{
    ElMessage.warning(res.message)
  }
}
const openData = (type,val) => {
  dialogRef.value.openDialog(type,val);
}
const getListAll = () => {
  getListPage()
  getList()
}
</script>
<template>
</template>
<style scoped lang="scss">
.app-container{
  .card-item{
    //height: 160px;
    margin-bottom: 10px;
    //min-width: 300px;
  }
  .grid-container{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(385px, 1fr));
    gap: 0px;
    justify-content: start;
    padding: 15px;
    background: #f7f7f7;
  }
  .title-font{
    display:flex;
    align-items: center;
    padding: 3px 15px;
    font-size: 14px;
    margin-right: 10px;
    border-radius: 5px
  }
  :deep(.is-horizontal) {
    height: 0;
    left: 0;
    display: none;
  }
  :deep(.el-scrollbar__wrap) {
    overflow-x: hidden;
  }
}
</style>