longyvfengyun
2024-07-30 9fcb3914d0df06033d5b8cfc5e5d33adc63ca6f1
审批提示
1个文件已修改
1个文件已添加
289 ■■■■■ 已修改文件
src/components/ApproveDialog.vue 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/index.vue 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/ApproveDialog.vue
New file
@@ -0,0 +1,71 @@
<script>
import createWs from "@/assets/js/websocket";
const WSMixin = createWs("hrTmpFlow");
export default {
  name: "ApproveDialog",
  mixins: [WSMixin],
  data() {
    return {
      isFirstShow: true,
    };
  },
  methods: {
    onWSOpen() {
      this.$nextTick(() => {
        this.sendMessage();
      });
    },
    sendMessage() {
      if (!this.isWSOpen) {
        return false;
      }
      let params = {
        pageNum: 1,
        pageSize: 10,
        type: 0, // 流程类型
        status: 1, // 状态-审批中
      };
      // console.log("=====9=", params, JSON.stringify(params));
      this.SOCKET.send(JSON.stringify(params));
    },
    onWSMessage(res) {
      res = JSON.parse(res.data);
      if (res.code === 1 && res.data && this.isFirstShow) {
        let approveNum = res.data.statistics.data[1];
        if (approveNum) {
          this.$confirm(
            "存在需要审批的任务:" + approveNum + "个",
            "系统提示",
            {
              confirmButtonText: "去审批",
              cancelButtonText: "取消",
              type: "info",
            }
          )
            .then(() => {
              this.$router.push("/OPSAllocation/flowManage");
            })
            .catch(() => {});
        }
      }
      this.isFirstShow = false;
    },
  },
  computed: {
    isWSOpen: {
      cache: false,
      get() {
        return this.SOCKET && 1 == this.SOCKET.readyState;
      },
    },
  },
  mounted() {},
};
</script>
<template>
  <div></div>
</template>
<style scoped></style>
src/layout/index.vue
@@ -1,13 +1,17 @@
<template>
  <div :class="classObj" class="main-warp">
    <div
      v-if="sidebar.opened"
      class="drawer-bg"
      @click="handleClickOutside"
    />
    <audio :src="speakSrc" v-show="false" controls autoplay @error="endSpeak" @ended="endSpeak" v-if="isShowSpeak">
    <div v-if="sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
    <audio
      :src="speakSrc"
      v-show="false"
      controls
      autoplay
      @error="endSpeak"
      @ended="endSpeak"
      v-if="isShowSpeak"
    >
      <source :src="speakSrc" type="audio/ogg" />
      <source :src="speakSrc" type="audio/mpeg"/>
      <source :src="speakSrc" type="audio/mpeg" />
      <source :src="speakSrc" type="audio/wav" />
    </audio>
    <sidebar />
@@ -24,18 +28,30 @@
        </div>
      </flex-layout>
    </div>
    <alarm-popup v-if="showAlarmPopup" :speakInfo="speakInfo" :list="newOneLevelItems" :updateFlag="updateFlag"></alarm-popup>
    <alarm-popup
      v-if="showAlarmPopup"
      :speakInfo="speakInfo"
      :list="newOneLevelItems"
      :updateFlag="updateFlag"
    ></alarm-popup>
    <approve-dialog></approve-dialog>
  </div>
</template>
<script>
import {mapGetters} from "vuex";
import { mapGetters } from "vuex";
import { Navbar, Sidebar, AppMain, TagsView } from "./components";
import ResizeMixin from "./mixin/ResizeHandler";
import marqueeLeft from "./components/marqueeLeft";
import {checkUserLogin, delVoice, getAlarmVoiceSetting, getAllRealAlarm, getVoiceList} from "@/layout/js/api";
import {const_alarm_level} from "@/assets/js/const";
import {getLabelByValue} from "@/assets/js/tools";
import {
  checkUserLogin,
  delVoice,
  getAlarmVoiceSetting,
  getAllRealAlarm,
  getVoiceList,
} from "@/layout/js/api";
import { const_alarm_level } from "@/assets/js/const";
import { getLabelByValue } from "@/assets/js/tools";
import config from "@/assets/js/config";
let timer;
import createWs from "@/assets/js/websocket/plus";
@@ -43,6 +59,7 @@
import getNowStamp from "@/assets/js/tools/getNowStamp";
import getWebUrl from "@/assets/js/tools/getWebUrl";
import getFileName from "@/assets/js/tools/getFileName";
import ApproveDialog from "@/components/ApproveDialog.vue";
const WSMixin = createWs("battAlarmFoot", "loginCheck", "sendAlarmData");
// import getWsUrl from '@/assets/js/websocket/getWsUrl';
const times = 10 * 1000;
@@ -50,12 +67,13 @@
export default {
  name: "Layout",
  components: {
    ApproveDialog,
    AlarmPopup,
    Navbar,
    Sidebar,
    AppMain,
    TagsView,
    marqueeLeft
    marqueeLeft,
  },
  data() {
    let baseUrl = getWebUrl();
@@ -75,7 +93,7 @@
      isShowSpeak: false,
      speakInfo: {
        devId: "608700010",
        almId: "119020"
        almId: "119020",
      },
      timeoutId: 0,
    };
@@ -95,12 +113,12 @@
      }
    },
    "$store.state.user.noSpeak"(val) {
      console.log(val+"**********");
      console.log(val + "**********");
      this.endSpeak();
    }
    },
  },
  computed: {
    ...mapGetters("user", ['noSpeak']),
    ...mapGetters("user", ["noSpeak"]),
    sidebar() {
      return this.$store.state.app.sidebar;
    },
@@ -118,7 +136,7 @@
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === "mobile"
        mobile: this.device === "mobile",
      };
    },
    showMarqueeLeft() {
@@ -127,11 +145,11 @@
        : true;
    },
    newOneLevelItems() {
      return this.list.filter(item=>{
      return this.list.filter((item) => {
        //return item;
        return item.almLevel==1 && item.almSeverity == 1;
        return item.almLevel == 1 && item.almSeverity == 1;
      });
    }
    },
    // isWSOpen2 () {
    //     return !!(this.SOCKET2 && 1 == this.SOCKET2.readyState);
    //   }
@@ -146,7 +164,7 @@
    },
    onWSMessage1(res) {
      let resData = JSON.parse(res.data);
      this.list = resData.data.map(item=>{
      this.list = resData.data.map((item) => {
        item.stationObj = {
          stationName: item.stationName,
          stationName1: item.stationName1,
@@ -154,11 +172,15 @@
          stationName3: item.stationName3,
          stationName4: item.stationName4,
          stationName5: item.stationName5,
        }
        item.alarmLevel = getLabelByValue(item.almLevel, const_alarm_level.levelNumber, "----");
        };
        item.alarmLevel = getLabelByValue(
          item.almLevel,
          const_alarm_level.levelNumber,
          "----"
        );
        let alarmType = Number(item.alarmType);
        let alarmPoint = "";
        switch(alarmType) {
        switch (alarmType) {
          case 1:
            alarmPoint = "设备告警";
            break;
@@ -174,10 +196,10 @@
        return item;
      });
      this.newItems = this.list.filter(item=>{
      this.newItems = this.list.filter((item) => {
        let nowStamp = getNowStamp();
        let inputDate = Date.parse(item.almStartTime); //输入时间戳
        return (nowStamp - inputDate) < 60*60*24*1000;
        return nowStamp - inputDate < 60 * 60 * 24 * 1000;
      });
      this.updateFlag = Math.random();
    },
@@ -215,7 +237,7 @@
    //     //     });
    // },
    // 互斥通讯
    onWSMessage2: function(res) {
    onWSMessage2: function (res) {
      //console.log(res)
      let resData = JSON.parse(res.data);
      if (!resData.data.checkLogin.data) {
@@ -230,7 +252,7 @@
        }, 2000);
      }
    },
    onWSOpen2: function() {
    onWSOpen2: function () {
      console.log("通讯成功");
    },
    onWSOpen3() {
@@ -240,7 +262,7 @@
      let userId = sessionStorage.getItem("userId");
      this.SOCKET3.send(Number(userId));
    },
    onWSMessage3: function(res) {
    onWSMessage3: function (res) {
      let resData = JSON.parse(res.data);
    },
    // onWSError2:function(Event){
@@ -260,63 +282,67 @@
    // },
    handleClickOutside() {
      this.$store.dispatch("app/closeSideBar", {
        withoutAnimation: false
        withoutAnimation: false,
      });
    },
    getVoiceList() {
      getVoiceList().then(res=>{
        let baseUrl = this.baseUrl;
        let rs = res.data;
        let list = [];
        if(rs.code == 1 && rs.data) {
          list = rs.data2.map(item=>{
            return {
              url: baseUrl+item,
              fileFullName: getFileName(item),
            }
          });
        }
        this.speakSrcList = list;
        if(!this.isClose) {
          this.endSpeak();
        }
      }).catch(error=>{
        if(!this.isClose) {
          this.endSpeak();
        }
        console.log(error);
      });
      getVoiceList()
        .then((res) => {
          let baseUrl = this.baseUrl;
          let rs = res.data;
          let list = [];
          if (rs.code == 1 && rs.data) {
            list = rs.data2.map((item) => {
              return {
                url: baseUrl + item,
                fileFullName: getFileName(item),
              };
            });
          }
          this.speakSrcList = list;
          if (!this.isClose) {
            this.endSpeak();
          }
        })
        .catch((error) => {
          if (!this.isClose) {
            this.endSpeak();
          }
          console.log(error);
        });
    },
    delVoice(fileFullName) {
      if(!this.fileFullName) {
      if (!this.fileFullName) {
        this.handleNextSpeak();
        return;
      }
      delVoice(fileFullName).then(res=>{
        let rs = res.data;
        if(rs.code == 1) {
          console.log("删除:"+fileFullName+"成功");
        }
        this.handleNextSpeak();
      }).catch(error=>{
        console.log(error);
        this.handleNextSpeak();
      });
      delVoice(fileFullName)
        .then((res) => {
          let rs = res.data;
          if (rs.code == 1) {
            console.log("删除:" + fileFullName + "成功");
          }
          this.handleNextSpeak();
        })
        .catch((error) => {
          console.log(error);
          this.handleNextSpeak();
        });
    },
    endSpeak() {
      this.speakInfo = {
        devId: 0,
        almId: 0
        almId: 0,
      };
      this.delVoice(this.fileFullName);
    },
    handleNextSpeak() {
      if(this.speakSrcList.length == 0) {
      if (this.speakSrcList.length == 0) {
        console.log("全部播放完成");
        setTimeout(()=>{
        setTimeout(() => {
          this.getVoiceList();
        }, 2000);
      }else {
      } else {
        this.isShowSpeak = false;
        let voiceInfo = this.speakSrcList.pop();
        this.speakSrc = voiceInfo.url;
@@ -324,38 +350,42 @@
        let fileInfos = voiceInfo.fileFullName.split("_");
        this.speakInfo = {
          devId: fileInfos[3],
          almId: fileInfos[4]
          almId: fileInfos[4],
        };
        this.$nextTick(()=>{
          this.isShowSpeak = this.noSpeak?false:true;
        this.$nextTick(() => {
          this.isShowSpeak = this.noSpeak ? false : true;
        });
      }
    },
    getAlarmVoiceSetting() {
      getAlarmVoiceSetting().then(res=>{
        let rs = res.data;
        if(rs.code == 1) {
          let data = rs.data;
          this.$store.dispatch('user/changeNoSpeak', data.beeperSoundOff?true:false);
        }
        //this.endSpeak();
      }).catch(error=>{
        //this.endSpeak();
      });
      getAlarmVoiceSetting()
        .then((res) => {
          let rs = res.data;
          if (rs.code == 1) {
            let data = rs.data;
            this.$store.dispatch(
              "user/changeNoSpeak",
              data.beeperSoundOff ? true : false
            );
          }
          //this.endSpeak();
        })
        .catch((error) => {
          //this.endSpeak();
        });
    },
    resetTimeout() {
      clearTimeout(this.timeoutId); // 清除之前的定时器
      this.timeoutId = window.setTimeout(()=>{
      this.timeoutId = window.setTimeout(() => {
        // 超时后的操作
        this.$alert('超过30分钟未操作,系统自动退出!', '系统提示', {
        this.$alert("超过30分钟未操作,系统自动退出!", "系统提示", {
          type: "warning",
          confirmButtonText: '确定',
          confirmButtonText: "确定",
        });
        // 退出登录
        this.outSystem();
      }, 30*60*1000); // 重置为30分钟
      }, 30 * 60 * 1000); // 重置为30分钟
    },
    outSystem() {
      sessionStorage.removeItem("username");
@@ -377,21 +407,21 @@
    this.getAlarmVoiceSetting();
    // 开启超时30分钟未操作,退出登录
    if(config.autoExit.value) {
    if (config.autoExit.value) {
      this.resetTimeout();
      // 绑定用户交互事件以重置定时器
      document.addEventListener('click', this.resetTimeout);
      document.addEventListener('mousemove', this.resetTimeout);
      document.addEventListener('keydown', this.resetTimeout);
      document.addEventListener("click", this.resetTimeout);
      document.addEventListener("mousemove", this.resetTimeout);
      document.addEventListener("keydown", this.resetTimeout);
    }
  },
  destroyed() {
    this.isClose = true;
    // 销毁后移除监听
    document.removeEventListener('click', this.resetTimeout);
    document.removeEventListener('mousemove', this.resetTimeout);
    document.removeEventListener('keydown', this.resetTimeout);
  }
    document.removeEventListener("click", this.resetTimeout);
    document.removeEventListener("mousemove", this.resetTimeout);
    document.removeEventListener("keydown", this.resetTimeout);
  },
};
</script>