| | |
| | | }, |
| | | data() { |
| | | return { |
| | | onLine: navigator.onLine, // 监听网络是否在线 |
| | | |
| | | headTime: '', |
| | | |
| | | purchaseLeftTopData: [], |
| | |
| | | number1: '', |
| | | |
| | | MarqueeTipsContent: '', // 公告 |
| | | speed: 100// 公告播放的速度 |
| | | speed: 100, // 公告播放的速度 |
| | | |
| | | PurchaseLeftTop: null, |
| | | PurchaseLeftBottom: null, |
| | | PurchaseRight: null |
| | | } |
| | | }, |
| | | |
| | |
| | | setInterval(this.getNowTime, 1000) |
| | | }, |
| | | mounted() { |
| | | window.addEventListener('online', this.updateOnlineStatus) |
| | | window.addEventListener('offline', this.updateOnlineStatus) |
| | | this.updateOnlineStatus({ type: this.onLine ? 'online' : 'offline', isFirst: true }) |
| | | }, |
| | | beforeDestroy() { |
| | | window.removeEventListener('online', this.updateOnlineStatus) |
| | | window.removeEventListener('offline', this.updateOnlineStatus) |
| | | }, |
| | | methods: { |
| | | // 更新网络状态 |
| | | updateOnlineStatus(e) { |
| | | if (e.isFirst) { |
| | | this.getPurchaseLeftTop() |
| | | this.getPurchaseLeftBottom() |
| | | this.getPurchaseRight() |
| | | |
| | | this.getMarqueeTipsContent() |
| | | // this.getMarqueeTipsContent() |
| | | } else { |
| | | const loading = this.$loading({ |
| | | lock: true, |
| | | text: '断网了,正在拼命联网中,请检查网络是否正常...', |
| | | spinner: 'el-icon-loading', |
| | | customClass: 'osloading', |
| | | background: 'rgba(0, 0, 0, 0.7)' |
| | | }) |
| | | const { type } = e |
| | | this.onLine = type === 'online' |
| | | if (this.onLine) { |
| | | this.getPurchaseLeftTop() |
| | | this.getPurchaseLeftBottom() |
| | | this.getPurchaseRight() |
| | | // this.getMarqueeTipsContent() |
| | | loading.close() |
| | | this.$message.success('网络连接成功!') |
| | | } else { |
| | | clearInterval(this.PurchaseLeftTop) |
| | | clearInterval(this.PurchaseLeftBottom) |
| | | clearInterval(this.PurchaseRight) |
| | | this.$message.error('网络掉线,请关注网络状态!') |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | |
| | | // 获取公告 |
| | | getMarqueeTipsContent() { |
| | | // this.MarqueeTipsContent = '各位员工们:根据上级的通知,结合我企实际情况,现将20xx年的元旦放假通知如下:一、1月1日至1月3日放假调休,共3天。1月4日正式上班。二、节假日期间,各班组要严格落实上级的重要指示精神,按照上级的具体要求,认真抓好落实节日期间值班备勤工作,确保节日期间企业各项工作正常运转。xx企业20xx年12月28日' |
| | |
| | | this.purchaseLeftTopData = res.data[0] |
| | | // console.log(this.purchaseLeftTopData) |
| | | }) |
| | | setInterval(() => { |
| | | this.PurchaseLeftTop = setInterval(() => { |
| | | PurchaseLeftTop().then(res => { |
| | | this.purchaseLeftTopData = res.data[0] |
| | | }) |
| | | }, 1000 * 6) |
| | | }, |
| | | |
| | | getPurchaseLeftBottom() { |
| | | PurchaseLeftBottom().then(res => { |
| | | this.tableData = res.data |
| | |
| | | |
| | | const divData = this.$refs.tableData.bodyWrapper |
| | | // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果(此配置为每100毫秒移动1像素) |
| | | const task = setInterval(() => { |
| | | this.PurchaseLeftBottom = setInterval(() => { |
| | | // 元素自增距离顶部1像素 |
| | | divData.scrollTop += 1 |
| | | // 判断元素是否滚动到底部(可视高度+距离顶部=整个高度) |
| | |
| | | this.tableData = res.data |
| | | this.number1 = this.tableData.length |
| | | if (this.tableData.length > 14) { |
| | | clearInterval(task) |
| | | clearInterval(this.PurchaseLeftBottom) |
| | | this.getPurchaseLeftBottom() |
| | | } |
| | | }) |
| | |
| | | }, this.tableData.length <= 14 ? 1000 * 3 : 100) |
| | | }) |
| | | }, |
| | | |
| | | getPurchaseRight() { |
| | | PurchaseRight().then(res => { |
| | | this.tableDataRank = res.data |
| | | const divData = this.$refs.tableDataRank.bodyWrapper |
| | | // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果(此配置为每100毫秒移动1像素) |
| | | const task = setInterval(() => { |
| | | this.PurchaseRight = setInterval(() => { |
| | | // 元素自增距离顶部1像素 |
| | | divData.scrollTop += 1 |
| | | // 判断元素是否滚动到底部(可视高度+距离顶部=整个高度) |
| | |
| | | PurchaseRight().then(res => { |
| | | this.tableDataRank = res.data |
| | | if (this.tableDataRank.length > 21) { |
| | | clearInterval(task) |
| | | clearInterval(this.PurchaseRight) |
| | | this.getPurchaseRight() |
| | | } |
| | | }) |