jhwxapp/miniprogram/pages/shebieguanli-jxsb/shajiangguan.js

224 lines
5.1 KiB
JavaScript

// pages/new-shebeiguanli/shebeiguanli.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
active:1,
show:false,
leftShow:false,
showType: false,
type:"全部",
actionsType: [],
list:[],
machineCount:"0",
workingCount:"0",
idlingCount:"0",
offCount:"0",
outWatchingCount:"0",
machineryTotalCount:'0',
machineryTotalList:[],
//基础参数
projectId:'',
projectName:'' ,
loginName:'',
userName:'',
initData:{}
},
//项目切换 返回值
onProjectSelect(e){
this.onClickShow();
let projectId = e.detail.id;
let projectName = e.detail.text;
app.globalData.projectId = projectId;
app.globalData.projectName = projectName;
this.setData({
projectId:projectId,
projectName:projectName
})
this.onLoad();
},
showPopup() {
this.setData({ leftShow: true });
},
onLeftClose(){
this.setData({ leftShow: false });
},
onClose() {
this.setData({ showType: false });
},
onclickType(){
this.setData({ showType: true });
},
onSelectType(event) {
this.onClickShow();
this.setData({
type: event.detail.name,
});
this.selectMachineryRun(this.data.projectId,(event.detail.name == "全部")?'':event.detail.name);
},
//页面加载
onClickShow() {
this.setData({ show: true });
},
onClickHide() {
this.setData({ show: false });
},
// 底部导航
onChange(event) {
// event.detail 的值为当前选中项的索引
this.setData({ active: event.detail });
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.onClickShow();
var that = this;
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success:function(res){
that.setData({
loginName:res.data.loginName,
userName:res.data.userName,
projectId:app.globalData.projectId,
projectName:app.globalData.projectName,
initData:{text:app.globalData.projectName,id:app.globalData.projectId}
})
}
})
//查询出机械设备基础信息
this.selectMachineryRun(app.globalData.projectId,'');
//查询出机械类型
this.selectMachineCategory(app.globalData.projectId);
},
//查询出机械设备的基础数据
selectMachineryRun:function(event,event1){
var that = this;
wx.request({
url: app.globalData.reqUrl+'/weixin/machicnery/selectMachineryRun',
data:{
"projectId":event,
"category":event1
},
method:"GET",
success:function(res){
that.setData({
machineCount:res.data.count,
workingCount:res.data.working,
idlingCount:res.data.idling,
offCount:res.data.off,
outWatchingCount:res.data.outWatching,
list:res.data.partMachineryList,
machineryTotalCount:res.data.totalMachineryListCount,
machineryTotalList:res.data.totalMachineryList,
})
that.onClickHide();
}
})
},
//查询出机械类型
selectMachineCategory:function(event){
var that = this;
wx.request({
url: app.globalData.reqUrl+'/weixin/machicnery/selectMachineCategory',
data:{
"projectId":event,
"type":"shouye"
},
method:"GET",
success:function(res){
that.setData({
actionsType:res.data
})
}
})
},
//点击单个机械跳转到地图页面
skipMap:function(event){
wx.redirectTo({
url: '../shebeiguanli-map/jixiedingwei?machineryTotalList='+JSON.stringify(this.data.machineryTotalList)+"&index="+event.currentTarget.dataset.index+"&machineKey="+event.currentTarget.dataset.machinekey+"&skipState=1"+"&type="+this.data.type
})
},
//查询所有设备信息
shipTotalMap:function(event){
wx.redirectTo({
url: '../shebeiguanli-map/jixiedingwei?machineryTotalList='+JSON.stringify(this.data.machineryTotalList)+"&skipState=2"+"&type="+this.data.type
})
},
//跳转到项目概况页面
XMGK:function(){
wx.redirectTo({
url: '../xiangmugaikuang/xiangmugaikuang'
})
},
//跳转到人员管理
RYGL:function(){
wx.redirectTo({
url: '../renyuanguanli/renyuanguanli'
})
},
//跳转到安全管控
XMSP:function(){
wx.redirectTo({
//url: '../deepExcavation/index'
url:'../newAddPage/safetyManagement/index'
})
},
//跳转到更多更能
GDGN:function(event){
wx.redirectTo({
url: '../gengduogongneng/gengduogongneng',
})
},
//退出登录
TCDL:function(){
wx.clearStorageSync();
wx.setStorageSync('isReload', "1")
wx.redirectTo({
url: '../login/login',
})
},
//跳转到特种设备
gotzsb:function(event){
wx.redirectTo({
url: '../shebieguanli-tzsb/taji'
})
},
//返回到工程列表页面
goGCLB:function(){
wx.redirectTo({
url: '../gongchengliebiao/gongchengliebiao'
})
},
//返回到地图页面
GOMAP:function(){
wx.redirectTo({
url: '../map/map',
})
},
})