ZZJ
2021-11-24 bbe33e5fd87e5961fdab804bfb0b4cf354e0c5b2
src/pages/internetEquipment/module/historyModule.vue
@@ -1,62 +1,71 @@
<template>
  <div class="history-module">
      <div class="title">历史报警</div>
      <div class="history-item"
      v-for="(item,index) in warnArrProcess"
      :key="index">
        <warnDescription
        :warnDes="{code:item.code,
        time:item.time,
        warn:item.warn}"/>
        <div 
        class="button"
        @click="process(item)">处理</div>
      class="history-item"
      v-for="(item, index) in warnArrProcess"
      :key="index"
    >
      <warnDescription
        :warnDes="{
          code: item.device_sn,
          time: item.updated_at,
          warn: item.isLowBattery == 1 ? '低电量预警' : '实时抓拍预警',
        }"
      />
      <div class="button" @click="process(item)">处理</div>
      </div>
      <processWarn 
      v-if="activeWarn" 
      :warnObj="activeWarn" 
      @close="close" 
      @save="save"/>
      @save="save"
    />
      <div class="mask"  v-if="activeWarn"/>
  </div>
</template>
<script>
import warnDescription from '@/pages/internetEquipment/components/warnDescription'
import processWarn from '@/pages/internetEquipment/components/processWarn'
import warnDescription from "@/pages/internetEquipment/components/warnDescription";
import processWarn from "@/pages/internetEquipment/components/processWarn";
import { handleWarn } from "@/api/helemt";
export default {
    data (){
        return {
            activeWarn:null
        }
      activeWarn: null,
    };
    },
    props :{
        warnArr : {
            type: Array
        }
      type: Array,
    },
    },
    components :{
        warnDescription,
        processWarn
    processWarn,
    },
    computed :{
        warnArrProcess(){
            return this.warnArr.filter(item=>!item.processed)
        }
      return this.warnArr.filter((item) => item.status != 1);
    },
    },
    methods: {
        process(item){
            this.activeWarn = item
      this.activeWarn = item;
        },
        close(){
            this.activeWarn =null
      this.activeWarn = null;
        },
        save(item) {
            this.$set(item,'processed',true)
            this.close()
        }
    }
}
      console.log(item);
      handleWarn({ id: item.id }).then((res) => {
        this.$set(item, "status", 1);
        this.close();
      });
    },
  },
};
</script>
<style scoped lang="scss">
@@ -83,17 +92,17 @@
        margin-bottom: 4px;
        align-items: center;
        justify-content: space-between;
        background: #F9FAFC;
    background: #f9fafc;
        border-radius: 10px;
        padding: 0 10px;
        .button {
            width: 54px;
            height: 20px;
            background: #CFEEE0;
      background: #cfeee0;
            border-radius: 30px;
            font-size: 12px;
            line-height: 20px;
            color: #11AA66;
      color: #11aa66;
            cursor: pointer;
        }
    }
@@ -107,7 +116,7 @@
    text-align: center;
    z-index: 1;
    background-color: black;
    opacity: .5;
    opacity: 0.5;
    }
}
</style>