var Constant = require('../../utils/constant.js');
|
var app = getApp();
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
navBarIndex: 0,
|
curGrpTabName: '', //当前顶部导航栏的菜单名称
|
worryCount: '', //总隐患条数
|
scrollLeft: 0, //顶部导航栏每个标题之间的间距
|
userInfo: '', //用户基本信息
|
productId: '', //产品id
|
employeeID: '', //员工id
|
day: '', //查询的产品日期
|
groupNameList: [], //顶部导航标签数组
|
contentList: [], //内容数组
|
inspectNote: '', //巡检记录的备注
|
inspectFiles: [], //巡检记录的图片路径
|
modalName: '', //当前滑动的项
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function (options) {
|
this.setData({
|
employeeID: options.EmployeeID,
|
productId: options.ProductID,
|
day: options.Day,
|
userInfo: app.globalData.userInfo
|
});
|
wx.setNavigationBarTitle({
|
title: options.Day + '巡检记录'
|
})
|
|
var userInfo = this.data.userInfo;
|
//console.log('登录之后的用户信息', userInfo)
|
if (userInfo == null) {
|
wx.redirectTo({
|
url: '/login/login/index',
|
})
|
return;
|
} else {
|
this.setData({
|
userInfo: app.globalData.userInfo,
|
});
|
}
|
this.getRecordDetail()
|
},
|
//获取记录详情
|
getRecordDetail: function () {
|
var that = this
|
wx.showLoading({
|
title: '数据获取中...',
|
})
|
let EmployeeID = that.data.employeeID
|
let ProductID = that.data.productId
|
let Day = that.data.day
|
wx.request({
|
method: 'GET',
|
cache: false,
|
url: Constant.BASE_SERVER_URL + 'repair/Mobile/InspectRecord/GetRecordDetail',
|
data: {
|
CorpID: Constant.CorpID,
|
EmployeeID: EmployeeID,
|
ProductID: ProductID,
|
Day: Day
|
},
|
success: res => {
|
wx.hideLoading()
|
// console.log(res, '59')
|
let result = res.data
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '提示',
|
content: result.Message,
|
})
|
return;
|
}
|
var details = result.Data.Details;
|
if (details == null || details.length == 0)
|
return;
|
// console.log(res, '巡检内容打印')
|
//console.log(details);
|
|
var defaultGroupName = details[0].GroupName
|
|
let groupNameList = [] //顶部到导航栏组名数组
|
let contentList = [] //内容数组
|
let worryTotalCount = 0 //隐患条数
|
let inspectFiles = [] //图片存放位置
|
|
if (result.Data.Files != null) {
|
for (let j = 0; j < result.Data.Files.length; j++) {
|
inspectFiles.push(result.Data.Files[j].Path)
|
}
|
}
|
for (let i = 0; i < details.length; i++) {
|
let item = details[i];
|
item.OldValue = item.Value;
|
if (item.ValueStatus == 2) {
|
worryTotalCount = worryTotalCount + 1;
|
}
|
//处理值类型
|
this.handleValue(item)
|
|
//设置样式
|
this.setContentDetailStyle(item);
|
|
if (groupNameList.indexOf(item.GroupName) == -1) {
|
groupNameList.push(item.GroupName);
|
}
|
item.isShowTipInfo = false; //提示对话框弹出的动画状态
|
|
if (item.ValueRangeMax != null && item.ValueRangeMin == null)
|
item.TipInfo = item.TipInfo + " 正常值小于" + item.ValueRangeMax;
|
if (item.ValueRangeMax == null && item.ValueRangeMin != null)
|
item.TipInfo = item.TipInfo + " 正常值大于" + item.ValueRangeMin;
|
if (item.ValueRangeMax != null && item.ValueRangeMin != null)
|
item.TipInfo = item.TipInfo + " 正常值在" + item.ValueRangeMin + " ~ " + item.ValueRangeMax;
|
|
|
// groupList.push({
|
// GroupName: item.GroupName
|
// })
|
contentList.push(item)
|
}
|
that.setData({
|
curGrpTabName: defaultGroupName,
|
groupNameList: groupNameList,
|
contentList: contentList,
|
recordId: result.Data.RecordID,
|
inspectNote: result.Data.Note,
|
inspectFiles: inspectFiles,
|
worryCount: worryTotalCount
|
})
|
// console.log(result.Data)
|
},
|
fail: err => {
|
console.log(err)
|
}
|
})
|
},
|
//处理值类型对应的参数值
|
handleValue: function (record) {
|
// console.log(record)
|
if (record.ValueType == 3) {
|
if (record.Value == 1) {
|
record.Value = "正常"
|
}
|
if (record.Value == 0) {
|
record.Value = "异常"
|
}
|
return record
|
}
|
},
|
//设置样式
|
setContentDetailStyle(recordContent) {
|
if (recordContent.ValueStatus == 2) {
|
recordContent.valueDispClass = "worryValue";
|
recordContent.statusDispClass = "cuIcon-warn text-grey";
|
} else if (recordContent.ValueStatus == 1) {
|
recordContent.statusDispClass = "cuIcon-roundcheckfill text-grey";
|
recordContent.valueDispClass = "normalValue";
|
} else {
|
recordContent.statusDispClass = "cuIcon-title text-white";
|
recordContent.valueDispClass = "normalValue";
|
}
|
},
|
//查看照片
|
tapViewImage(e) {
|
// console.log(e)
|
wx.previewImage({
|
showmenu: true,
|
urls: this.data.inspectFiles, //this.data.imageList,
|
current: e.currentTarget.dataset.url,
|
success: res => {
|
console.log(res, '图片预览成功')
|
},
|
fail: err => {
|
console.log(err, '图片预览失败')
|
}
|
});
|
},
|
|
// ListTouch触摸开始
|
ListTouchStart(e) {
|
this.setData({
|
ListTouchStart: e.touches[0].pageX
|
})
|
},
|
|
// ListTouch计算方向
|
ListTouchMove(e) {
|
this.setData({
|
ListTouchDirection: e.touches[0].pageX - this.data.ListTouchStart > -50 ? 'right' : 'left'
|
})
|
},
|
|
// ListTouch计算滚动
|
ListTouchEnd(e) {
|
if (this.data.ListTouchDirection == 'left') {
|
this.setData({
|
modalName: e.currentTarget.dataset.target
|
})
|
} else {
|
this.setData({
|
modalName: null
|
})
|
}
|
this.setData({
|
ListTouchDirection: null
|
})
|
},
|
|
//跳转到单个巡检点的历史详情
|
jumpSinglePointDetail: function (e) {
|
// console.log(e)
|
let valueType = e.currentTarget.dataset.valueType
|
let item = JSON.stringify(e.currentTarget.dataset.item)
|
wx.navigateTo({
|
url: '../historyBySinglePointDetail/index?valueType=' + valueType + '&item=' + item,
|
})
|
},
|
|
|
//消除隐患
|
clearnWorry: function (e) {
|
|
},
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function () {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh: function () {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom: function () {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage: function () {
|
|
}
|
})
|