qa-prevention-gwj-first-app/pages/basics/home.vue

906 lines
25 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template name="basics">
<view>
<!-- #ifdef APP-PLUS -->
<view class="status_bar">
<view class="top_view"></view>
</view>
<!-- #endif -->
<mescroll-uni ref="mescrollRef" :top="StatusBar+'px'" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
<view class="banner">
<view></view>
<view>首页</view>
<view class="icon-ui" @click="$noMultipleClicks(scan)">
<text class="cuIcon-scan"></text>
</view>
</view>
<view class="options">
<view class="girds">
<template v-for="(item,index) in girdList">
<view class="gird" :key="index" v-if="item.condition">
<navigator class="a" hover-class="none" :url="item.url">
<view class="image">
<image :src="item.image" mode=""></image>
</view>
<view class="title">
<text>{{ item.title }}</text>
</view>
</navigator>
</view>
</template>
</view>
<view class="broadcast">
<view class="left">隐患播报</view>
<!-- <view class="right" @click="$noMultipleClicks(goToRecord)">-->
<view class="right">
<swiper
style="height: 126upx"
:indicator-dots="false"
:autoplay="true"
:interval="2000"
:duration="1000"
:circular="true"
:vertical="true"
:display-multiple-items="2"
>
<swiper-item v-for="item of hiddenList" :key="item.HIDDEN_ID">
<view class="item" @click="$noMultipleClicks(goToRecordDetail, item.HIDDEN_ID)">
<text class="u-line-1">{{item.HIDDENDESCR}}</text>
<text>{{item.findUserNames?item.findUserNames:'暂无'}}</text>
<text>{{item.DISCOVERYTIME? formatDate(item.DISCOVERYTIME):'暂无'}}</text>
</view>
</swiper-item>
</swiper>
</view>
</view>
</view>
<!--<view class="high-risk-work">
<view class="home-work-title">
<view class="title">
<view class="q_title"></view>
<view class="text-black f30b">高危作业</view>
</view>
</view>
<view class="new-apps-box">
<view class="new-apps-warp">
<view class="new-apps-item" v-for="(item,index) in highRiskList" :key="index">
<navigator class="a" hover-class="none" :url="item.url">
<view class="image">
<image :src="item.image" mode=""></image>
</view>
<view class="title">
<text>{{ item.title }}</text>
</view>
</navigator>
</view>
</view>
</view>
</view>-->
<view class="home-work">
<view class="home-work-title">
<view class="title">
<view class="q_title"></view>
<view class="text-black f30b">我的工作</view>
</view>
<view class="this-date">{{today}}</view>
</view>
<view class="work-list">
<swiper class="swiper">
<swiper-item>
<view class="work-box">
<navigator class="swiper-item" hover-class="none" url="/pages/application/hidden-trouble-investigation/hidden-trouble-app/hidden-trouble-app?isIndex=1">
<view>
待排查
</view>
<view class="work-border wui-mt10">
{{hidCount.dpc}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none" url="/pages/application/hidden-danger-management/hidden-danger-confirm/hidden-danger-confirm-change">
<view>
待确认
</view>
<view class="work-border wui-mt10">
{{hidCount.dqr}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none" url="/pages/application/hidden-danger-management/hidden-danger-rectification/hidden-danger-rectification-change?isIndex=1">
<view>
待整改
</view>
<view class="work-border wui-mt10">
{{hidCount.dzg}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none" url="/pages/application/hidden-danger-management/hidden-danger-overdue/hidden-danger-overdue?isIndex=1">
<view>
已超期
</view>
<view class="work-border wui-mt10">
{{hidCount.ycq}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none" url="/pages/application/hidden-danger-management/hidden-danger-check/hidden-danger-check?isIndex=1">
<view>
待验收
</view>
<view class="work-border wui-mt10">
{{hidCount.dys}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none" url="/pages/application/hidden-danger-management/hidden-danger-finish/hidden-danger-finish?isIndex=1">
<view>
已验收
</view>
<view class="work-border wui-mt10">
{{hidCount.yys}}
</view>
</navigator>
</view>
</swiper-item>
</swiper>
</view>
</view>
<view class="home-work">
<view class="home-work-title">
<view class="title">
<view class="q_title"></view>
<view class="text-black f30b">安全环保检查</view>
</view>
</view>
<view class="work-list">
<swiper class="swiper">
<swiper-item>
<view class="work-box">
<navigator class="swiper-item" hover-class="none">
<view>
检查数
</view>
<view class="work-border wui-mt10">
{{safetyEnvironmentalCount.COUNT_INSPECTION}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none">
<view>
被检查数
</view>
<view class="work-border wui-mt10">
{{safetyEnvironmentalCount.COUNT_INSPECTED}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none">
<view style="white-space: nowrap;">
负责整改隐患数
</view>
<view class="work-border wui-mt10">
{{safetyEnvironmentalCount.COUNT_HIDDEN}}
</view>
</navigator>
<navigator class="swiper-item" hover-class="none">
<view>
隐患验收数
</view>
<view class="work-border wui-mt10">
{{safetyEnvironmentalCount.COUNT_HIDDEN_ACCEPT}}
</view>
</navigator>
</view>
</swiper-item>
</swiper>
</view>
</view>
<view class="home-date" v-if="false">
<view class="home-work-title">
<view class="title">
<view class="q_title"></view>
<view class="text-black f30b">排查数据</view>
</view>
<!-- <view class="this-date">更多</view> -->
</view>
<view class="home-date-list">
<view class="qd-date">
<view class="qd-date-item">
<view class="date text-blue">
{{hdCount.monthTotal}}
</view>
<view class="name">
发现隐患数
</view>
</view>
<view class="qd-date-item">
<view class="date text-orange">
{{hdCount.monthChecked}}
</view>
<view class="name">
已整改隐患数
</view>
</view>
<view class="qd-date-item">
<view class="date text-green">
{{hdCount.monthTotal==0?0:((hdCount.monthChecked/hdCount.monthTotal*100).toFixed(2))}}%
</view>
<view class="name">
隐患整改率
</view>
</view>
<view class="qd-tag bg-blue">
<text></text>
<text></text>
</view>
</view>
<view class="qd-date">
<view class="qd-date-item">
<view class="date text-blue">
{{hdCount.yearTotal}}
</view>
<view class="name">
发现隐患数
</view>
</view>
<view class="qd-date-item">
<view class="date text-orange">
{{hdCount.yearChecked}}
</view>
<view class="name">
已整改隐患数
</view>
</view>
<view class="qd-date-item">
<view class="date text-green">
{{hdCount.yearTotal==0?0:((hdCount.yearChecked/hdCount.yearTotal*100).toFixed(2))}}%
</view>
<view class="name">
隐患整改率
</view>
</view>
<view class="qd-tag bg-red">
<text></text>
<text></text>
</view>
</view>
</view>
</view>
<view class="cu-tabbar-height"></view>
</mescroll-uni>
</view>
</template>
<script>
import {
basePath,corpinfoId,loginUserId,formatDate,loginUser,setloginUserId,setCorpinfoId,setloginUser,setDeptId
} from '@/common/tool.js';
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
export default {
mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
data() {
return {
girdList:[
{
title:'基本资料',
url:'/pages/basics/basic-info/basic-info',
image:require('../../static/new_images/ico1.png'),
condition:true
},
{
title:'工作安排',
url:'/pages/basics/work-plan/work-plan',
image:require('../../static/new_images/ico2.png'),
condition:true
},
{
title:'风险分布',
url:'/pages/basics/risk-distribution/risk-distribution',
image:require('../../static/new_images/ico3.png'),
condition:true
},
{
title:'学习园地',
url:'/pages/application/onlinexxks/home',
image:require('../../static/new_images/ico4.png'),
condition:true
},
{
title:'高危作业',
url:'/pages/application/high-risk-work/home',
image:require('../../static/new_images/ico5.png'),
condition:true
},
{
title:'安全环保检查',
url:'/pages/application/safety-environmental-inspection/home',
image:require('../../static/new_images/ico6.png'),
condition:true
},
{
title:'消防管理',
url:'/pages/application/fire-management/hidden-trouble-app/hidden-trouble-app',
image:require('../../static/new_images/home-xiaofang.jpg'),
condition:true
},
{
title:'智能门禁管理',
url:'/pages/application/accesscontrol/home',
image:require('../../static/new_images/ico7.png'),
condition:loginUser.CORPINFO_ID ==='035958e685cf4850bc40151c5e0617a6' || loginUser.CORPINFO_ID ==='13cf0f4ec77e4d98ae8cdd9c3386ae0c'
},
{
title:'重点工程管理',
url:'/pages/application/key-project-management/index/index',
image:require('../../static/new_images/home-zdgcgl.png'),
condition:true
},
],
highRiskList:[
{
title:'动火作业',
url:'/pages/application/eight-assignments/index',
image:require('../../static/new_images/i1.png'),
},
{
title:'高处作业',
url:'/pages/application/high-risk-work/high-work/home',
image:require('../../static/new_images/i2.png'),
},
{
title:'盲板作业',
url:'/pages/application/high-risk-work/blind-work/index',
image:require('../../static/new_images/i3.png'),
},
{
title:'吊装作业',
url:'/pages/application/high-risk-work/lifting-safety-work/index',
image:require('../../static/new_images/i4.png'),
},
{
title:'有限空间安全作业',
url:'/pages/application/high-risk-work/limited-space/index',
image:require('../../static/new_images/i5.png'),
},
{
title:'临时用电安全作业',
url:'/pages/application/high-risk-work/electricity/index',
image:require('../../static/new_images/i6.png'),
},
],
page: 1,
rows: 10,
totalCount:0,
total:0,
isEnd: false,
hiddenList: [],
noClick:true,
StatusBar: this.StatusBar,
StatusBarb: this.StatusBar + 50,
hidCount: [],
safetyEnvironmentalCount: {},
hdCount:{},
today :'',
triggered: false,
totalList:[],
isGoodsEdit: false, // 是否加载编辑后的数据
downOption:{
mustToTop:true,
},
upOption: {
use: false, // 禁止上拉
toTop: {
src: '' // 不显示回到顶部按钮
}
},
loginUser :loginUser
};
},
mounted(){
// uni.startPullDownRefresh();
let now = new Date();
var today = formatDate(now, 'yyyy-MM-dd');
this.getData()
this.getHiddenData()
this.getSafetyEnvironmentalCount()
// this.getListData()
console.info(loginUser)
// this._freshing = false;
// setTimeout(() => {
// this.triggered = true;
// }, 1000)
},
// onPullDownRefresh() {
// console.log('refresh');
// setTimeout(function () {
// uni.stopPullDownRefresh();
// }, 1000);
// },
methods: {
//跳转事件
goToRecord(e) {
uni.navigateTo({
url: '/pages/application/hidden-danger-management/hidden-danger-record/hidden-danger-record',
});
},
goToRecordDetail(e) {
uni.navigateTo({
url: '/pages/application/hidden-danger-management/hidden-danger-record/hidden-danger-record-detail?id='+e,
});
},
async downCallback(page) {
await this.getWork();
await this.getHiddenData()
await this.getSafetyEnvironmentalCount()
// await this.getMonth();
// await this.getYear();
await this.mescroll.endSuccess();
this.mescroll.scrollTo( 0,100 )
},
getWork(){
return new Promise((resolve, reject) => {
var _this = this;
uni.request({
url: basePath + '/app/hidden/getCountByUserId',
method: 'POST',
dataType: 'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
userId: loginUserId,
CORPINFO_ID: loginUser.CORPINFO_ID,
USER_ID: loginUser.USER_ID,
USER_NAME: loginUser.NAME,
CHECK_DEPARTMENT_ID: loginUser.DEPARTMENT_ID,
IS_MAIN:loginUser.ISMAIN
},
success: (res) => {
if (res.data != null) {
_this.hidCount = res.data.hidCount;
resolve();
}
}
});
})
},
getMonth(){
return new Promise((resolve, reject) => {
var _this = this;
//月隐患数
uni.request({
url: basePath + '/app/hidden/getIndexCount',
method: 'POST',
dataType: 'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
userId: loginUserId,
},
success: (res) => {
if (res.data != null) {
_this.hdCount.monthTotal = res.data.total;
_this.hdCount.monthChecked = res.data.checked;
_this.hdCount.monthUncheck = res.data.uncheck;
this.$forceUpdate();
resolve();
}
}
});
})
},
getYear(){
return new Promise((resolve, reject) => {
var _this = this;
//年隐患数
uni.request({
url: basePath + '/app/hidden/getIndexCount',
method: 'POST',
dataType: 'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
userId: loginUserId,
},
success: (res) => {
if (res.data != null) {
_this.hdCount.yearTotal = res.data.total;
_this.hdCount.yearChecked = res.data.checked;
_this.hdCount.yearUncheck = res.data.uncheck;
this.$forceUpdate();
resolve();
}
}
});
})
},
getData() {
var _this = this;
let now = new Date();
_this.today = formatDate(now, 'yyyy-MM-dd');
uni.request({
url: basePath + '/app/hidden/getCountByUserId',
method: 'POST',
dataType: 'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
userId: loginUserId,
CORPINFO_ID: loginUser.CORPINFO_ID,
USER_ID: loginUser.USER_ID,
USER_NAME: loginUser.NAME,
CHECK_DEPARTMENT_ID: loginUser.DEPARTMENT_ID,
IS_MAIN:loginUser.ISMAIN
},
success: (res) => {
if (res.data != null) {
_this.hidCount = res.data.hidCount;
}
},
fail: (res) => {
uni.showToast({
icon: 'none',
title: "服务器正在升级,请稍后再试。",
duration: 2000
});
setTimeout(function() {
plus.runtime.quit();
// ios quit方法无效退出到登陆页
setloginUserId(null);
setCorpinfoId(null);
setDeptId(null);
setloginUser(null);
uni.removeStorage({key: 'USER'});
uni.navigateTo({
url: '/pages/login/home'
});
}, 2000);
}
});
//月隐患数
// uni.request({
// url: basePath + '/app/hidden/getIndexCount',
// method: 'POST',
// dataType: 'json',
// header:{
// 'Content-type':'application/x-www-form-urlencoded'
// },
// data: {
// userId: loginUserId,
// },
// success: (res) => {
// if (res.data != null) {
// _this.hdCount.monthTotal = res.data.total;
// _this.hdCount.monthChecked = res.data.checked;
// _this.hdCount.monthUncheck = res.data.uncheck;
// this.$forceUpdate();//强制刷新
// }
// }
// });
//年隐患数
// uni.request({
// url: basePath + '/app/hidden/getIndexCount',
// method: 'POST',
// dataType: 'json',
// header:{
// 'Content-type':'application/x-www-form-urlencoded'
// },
// data: {
// userId: loginUserId,
// },
// success: (res) => {
// if (res.data != null) {
// this.hdCount.yearTotal = res.data.total;
// _this.hdCount.yearChecked = res.data.checked;
// _this.hdCount.yearUncheck = res.data.uncheck;
// this.$forceUpdate();//强制刷新
// }
// }
// });
},
// 隐患播报
getHiddenData() {
return new Promise((resolve, reject) => {
var _this = this;
if (_this.isEnd) {
return
}
uni.showLoading({
title: '请稍候'
});
let DISPOSESTATE = 2;
uni.request({
url: basePath + '/app/hidden/list',
method: 'POST',
dataType: 'json',
header:{
'Content-type':'application/x-www-form-urlencoded'
},
data: {
tm:new Date().getTime(),
showCount:_this.rows,
currentPage:_this.page,
totalResult:_this.total,
DISPOSESTATE:-1,
USERDEPT:loginUser.DEPARTMENT_ID,
SELFUSERID:loginUserId,
CORPINFO_ID:corpinfoId
},
success: (res) => {
// console.info(res.data);
if (res.data.result == 'success') {
uni.hideLoading();
_this.total = res.data.page.totalResult;
_this.hiddenList = res.data.varList;
} else {
uni.showToast({
title: res.data.message,
duration: 2000
});
}
resolve()
}
})
});
},
// 获取清单数量
getListData(){
var _this=this;
uni.showLoading({
title: '加载中'
})
uni.request({
url: basePath + '/app/listmanager/checkList',
method: 'POST',
dataType: 'json',
header: {
'Content-type':'application/x-www-form-urlencoded'
},
data: {
CORPINFO_ID: loginUser.CORPINFO_ID,
USER_ID: loginUser.USER_ID,
USER_NAME: loginUser.NAME,
CHECK_DEPARTMENT_ID: loginUser.DEPARTMENT_ID,
IS_MAIN:loginUser.ISMAIN,
},
success: (res) => {
if("success" == res.data.result){
uni.hideLoading();
var content = res.data.varList;
for(var i=0;i<content.length;i++){
if(content[i].checkCount==0){
this.totalList.push(content[i]);
}else{
this.totalList.push(content[i]);
}
}
}else{
uni.showToast({
icon:'none',
title: '',
duration: 2000
});
}
},
fail: (res) => {
uni.showToast({
icon: 'none',
title: "服务器正在升级,请稍后再试。",
duration: 2000
});
setTimeout(function() {
plus.runtime.quit();
}, 2000);
}
})
},
getSafetyEnvironmentalCount(){
return new Promise((resolve, reject) => {
var _this = this;
uni.showLoading({
title:"加载中..."
});//加载中动画
uni.request({
url: basePath +'/app/safetyenvironmental/countHome',
method: 'POST',
dataType: 'json',
header: {
'Content-type':'application/x-www-form-urlencoded'
},
data: {
CORPINFO_ID:corpinfoId,
USER_ID:loginUser.USER_ID,
tm:new Date().getTime()
},
success: (res) => {
uni.hideLoading();//结束加载中动画
if ("success" == res.data.result) {
_this.safetyEnvironmentalCount = res.data.count;
}
resolve()
}
})
})
},
// refresh() {
// if (this._freshing) return;
// this._freshing = true;
// this.getData();
// setTimeout(() => {
// this.triggered = false;
// this._freshing = false;
// }, 1000)
// },
// refreshEnd() {
// this.triggered = 'restore'; // 需要重置
// console.log("onRestore");
// },
scan(){
let _this=this;
uni.scanCode({
success: function (res) {
let flag=false;
let listId = res.result;
for(var i=0;i<_this.totalList.length;i++){
if(_this.totalList[i].LISTMANAGER_ID==listId){
flag=true;
_this.goToList({listId:_this.totalList[i].LISTMANAGER_ID,listName:_this.totalList[i].NAME});
break;
}
}
if(!flag){
uni.showToast({
title: "",
duration: 2000
});
}
}
});
},
// scan(){
// let _this=this;
// uni.scanCode({
// success: function (res) {
// let flag=false;
// let unit = res.result;
// uni.navigateTo({
// url: '/pages/basics/risk-distribution/risk-distribution-forunit?unit='+unit
// });
// // _this.goToList({listId:_this.totalList[i].LISTMANAGER_ID,listName:_this.totalList[i].NAME});
// }
// });
// },
//跳转事件
goToexclude(e) {
this.$emit('setInit',true);
uni.navigateTo({
url: '/pages/basics/hidden-danger-exclude/exclude-list',
});
},
goToDanger(e) {
this.$emit('setInit',true);
uni.navigateTo({
url: '/pages/basics/danger-exclude/danger-exclude-list',
});
},
toSetinit(e) {
this.$emit('setInit',true);
},
//
goToList(e) {
uni.navigateTo({
url: '/pages/application/hidden-trouble-investigation/hidden-trouble-app/hidden-trouble-spot?listId='+e.listId+'&listName='+e.listName
});
// uni.navigateTo({
// url: '/pages/application/hidden-trouble-investigation/hidden-trouble-app/check-items-list?listId='+e.listId+'&listName='+e.listName
// });
},
formatDate(time) {
let date = new Date(time)
return formatDate(date, 'yyyy-MM-dd')
}
}
}
</script>
<style lang="scss" scoped>
.status_bar {
height: var(--status-bar-height);
width: 100%;
background-color: #022267;
}
.top_view {
height: var(--status-bar-height);
width: 100%;
position: fixed;
background-color: #022267;
top: 0;
z-index: 999;
}
.banner{
background-image: url("/static/new_images/banner.png");
background-size: 100% 100%;
background-repeat: no-repeat;
display: flex;
justify-content: space-between;
color: #fff;
font-size: 34upx;
padding: 20upx 5%;
}
.options{
background-color: #fff;
padding: 0 5% 30upx 3%;
border-radius: 50upx 50upx 0 0;
.girds{
display: flex;
flex-wrap: wrap;
.gird{
flex-basis: 25%;
margin-top: 30upx;
.a{
display: flex;
justify-content: center;
flex-wrap: wrap;
.image{
flex-basis: 100%;
text-align: center;
image{
width: 84upx;
height: 84upx;
}
}
.title{
flex-basis: 100%;
text-align: center;
margin-top: 10upx;
}
}
}
}
.broadcast{
display: flex;
margin-top: 50upx;
.left{
background-color: #0081ff;
color: #FFFFFF;
width: 100upx;
text-align: center;
padding: 20upx;
border-radius: 20upx 0 0 20upx;
}
.right{
height: 126upx;
background-color: #f8f9fe;
border-radius: 0 20upx 20upx 0;
flex: 1;
padding: 0 20upx;
display: flex;
flex-direction: column;
justify-content: space-between;
.item{
font-size: 30upx;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10upx 0;
border-bottom: 1px dashed #e4e5ea;
.u-line-1{
flex-basis: 40%;
}
}
}
}
}
.high-risk-work{
margin-top: 20upx;
background-color: #fff;
}
</style>