隐患跟踪

This commit is contained in:
caoqianming 2021-01-31 21:35:19 +08:00
parent f5e0dc422b
commit ab1c0f2c0b
15 changed files with 632 additions and 19 deletions

View File

@ -86,7 +86,9 @@
"pages/inspect/handle", "pages/inspect/handle",
"pages/train/access", "pages/train/access",
"pages/dickey/treeselect", "pages/dickey/treeselect",
"pages/troublefollow/index" "pages/troublefollow/index",
"pages/troublefollow/handle",
"pages/troublefollow/detail"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",

View File

@ -0,0 +1,84 @@
// pages/inspect/detail.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.request({
url: getApp().globalData.serverUrl + 'api/troublefollowtask?a=detail&id=' + options.id,
header: {
'content-type': 'application/json', //
'Cookie': getApp().globalData.sessionId,
},
method: 'GET',
success: res => {
if (res.statusCode === 200) {
this.setData(res.data)
}
}
})
},
previewImage: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: [current]
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@ -0,0 +1,48 @@
<view class="weui-cells__title">隐患跟踪任务信息</view>
<view class="weui-cells weui-cells_after-title">
<navigator url="/pages/trouble/troubledetail?troubleid={{trouble}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
<view class="weui-cell__bd">隐患编号</view>
<view class="weui-cell__ft weui-cell__ft_in-access">
<span style="color:darkblue">{{trouble__yhnum}}</span>
</view>
</navigator>
<view class="weui-cell">
<view class="weui-cell__bd">网格级别</view>
<view class="weui-cell__ft">{{gridlevel__dickeyname}}</view>
</view>
<view class="weui-cell">
<view class="weui-cell__bd">任务开启</view>
<view class="weui-cell__ft">{{taskadd}}</view>
</view>
<view class="weui-cell">
<view class="weui-cell__bd">任务关闭</view>
<view class="weui-cell__ft">{{taskexpire}}</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>跟踪备注</view>
<view class="weui-cell__ft">
{{tasknote}}
</view>
</view>
</view>
<view class="weui-cell ">
<view class="weui-cell__bd">任务状态</view>
<view class="weui-cell__ft">
<view wx:if="{{taskdo}}" style="color:green;font-weight:bold">已执行</view>
<view wx:else style="color:orange;font-weight:bold">未执行</view>
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__bd">执行时间</view>
<view class="weui-cell__ft" wx:if="{{taskdo}}">{{taskdo}}</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>跟踪描述</view>
<view class="weui-cell__ft" wx:if="{{desc}}">
{{desc}}
</view>
</view>
</view>
</view>

View File

@ -0,0 +1 @@
/* pages/troublefollow/detail.wxss */

View File

@ -0,0 +1,180 @@
// pages/inspect/detail.js
Page({
/**
* 页面的初始数据
*/
data: {
desc:'',
img:''
},
binddescInput: function (e) {
this.data.desc = e.detail.value
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.id=options.id;
wx.request({
url: getApp().globalData.serverUrl + 'api/troublefollowtask?a=detail&id=' + options.id,
header: {
'content-type': 'application/json', //
'Cookie': getApp().globalData.sessionId,
},
method: 'GET',
success: res => {
if (res.statusCode === 200) {
// if (res.data.img) {
// res.data.img = getApp().globalData.serverUrl + res.data.img
// }
this.setData(res.data)
}
}
})
},
previewImage: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: [current]
})
},
deleteImage: function (e) {
var that = this;
//var index = e.currentTarget.dataset.index; //获取当前长按图片下标
wx.showModal({
title: '系统提醒',
content: '确定要删除此图片吗?',
success: function (res) {
if (res.confirm) {
that.data.img2 = null
} else if (res.cancel) {
return false
}
that.setData({
img2: that.data.img2
});
}
})
},
chooseImage: function (e) {
var that = this
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
wx.showLoading({
title: '上传图片..',
mask: true
})
wx.uploadFile({
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
url: getApp().globalData.serverUrl + 'upfile',
filePath: res.tempFilePaths[0],
name: 'upfile',
success(res) {
wx.hideLoading()
var obj = JSON.parse(res.data);
that.data.img2 = getApp().globalData.serverUrl + obj['filepath']
that.setData({
img2: that.data.img2
})
},
complete: function (res) {
wx.hideLoading()
}
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
submit: function () {
var that = this
if(that.data.desc){
let data = {
id:that.data.id,
desc: that.data.desc,
}
// if (that.data.img2 && that.data.img2.indexOf(getApp().globalData.serverUrl) != -1) {
// data.img2 = data.img2.replace(getApp().globalData.serverUrl, '')
// }
wx.showLoading({
title: '提交中',
})
wx.request({
url: getApp().globalData.serverUrl + 'api/troublefollowtask/?a=handle',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
method: 'POST',
data: data,
success: res => {
wx.navigateBack({
})
wx.hideLoading();
}
});
}else{
wx.showToast({
title: '未填写跟踪描述',
icon:'none'
})
}
},
})

View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@ -0,0 +1,49 @@
<view class="weui-cells__title">隐患跟踪任务信息</view>
<view class="weui-cells weui-cells_after-title">
<!-- <view class="weui-cell">
<view class="weui-cell__bd">巡检人</view>
<view class="weui-cell__ft">{{user__name}}</view>
</view>
<view class="weui-cell">
<view class="weui-cell__bd">提交时间</view>
<view class="weui-cell__ft">{{creattime}}</view>
</view> -->
<navigator url="/pages/trouble/troubledetail?troubleid={{trouble}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
<view class="weui-cell__bd">隐患编号</view>
<view class="weui-cell__ft weui-cell__ft_in-access">
<span style="color:darkblue">{{trouble__yhnum}}</span>
</view>
</navigator>
<view class="weui-cell">
<view class="weui-cell__bd">网格级别</view>
<view class="weui-cell__ft">{{gridlevel__dickeyname}}</view>
</view>
<view class="weui-cell">
<view class="weui-cell__bd">任务开启</view>
<view class="weui-cell__ft">{{taskadd}}</view>
</view>
<view class="weui-cell">
<view class="weui-cell__bd">任务关闭</view>
<view class="weui-cell__ft">{{taskexpire}}</view>
</view>
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd weui-cell_primary">
<view>跟踪备注</view>
<view class="weui-cell__ft">
{{tasknote}}
</view>
</view>
</view>
</view>
<view class="weui-cells__title">跟踪描述</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea class="weui-textarea" placeholder="请输入跟踪查看的情况描述" style="height: 4.3em" bindinput="binddescInput" maxlength="-1"/>
</view>
</view>
</view>
<view class="btn-area ">
<button class="weui-btn" type="primary" bindtap="submit" >提交</button>
</view>

View File

@ -0,0 +1,4 @@
/* pages/inspect/handle.wxss */
.btn-area{
margin:5px
}

View File

@ -1,18 +1,47 @@
// pages/troublefollow/index.js
var sliderWidth = 96;
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
page: 1,
serverUrl: getApp().globalData.serverUrl,
todoList: [],
tabs: ["待执行任务", "已完成"],
activeIndex: 0,
sliderOffset: 0,
sliderLeft: 0
},
tabClick: function (e) {
var that = this
that.setData({
sliderOffset: e.currentTarget.offsetLeft,
activeIndex: e.currentTarget.id
});
if (that.data.activeIndex == 0) {
that.gettodoList(1)
that.data.page = 1
}
else if (that.data.activeIndex == 1) {
that.getdoneList(1)
that.data.page2 = 1
}
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
var that = this
wx.getSystemInfo({
success: function (res) {
that.setData({
sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
});
}
});
}, },
/** /**
@ -26,7 +55,8 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
var that = this;
that.onPullDownRefresh();
}, },
/** /**
@ -42,25 +72,133 @@ Page({
onUnload: function () { onUnload: function () {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () {
},
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () {
},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
} },
onPullDownRefresh: function () {
var that = this
if (that.data.activeIndex == 0) {
that.gettodoList(1)
that.data.page = 1
} else {
that.getdoneList(1)
that.data.page2 = 1
}
wx.stopPullDownRefresh();
},
onReachBottom: function () {
//上拉分页,将页码加1然后调用分页函数
var that = this
if (that.data.activeIndex == 0) {
that.data.page = that.data.page + 1
that.gettodoList()
} else {
that.data.page2 = that.data.page2 + 1
that.getdoneList()
}
},
gettodoList: function (page) {
var that = this;
if (page != 1) { page = that.data.page }
wx.showLoading({
title: '加载中',
}),
wx.request({
url: this.data.serverUrl + 'api/troublefollowtask?a=listtodo&rows=10&page=' + page,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
if (res.statusCode === 200) {
if (res.data.rows.length == 0) {
if (page == 1) {
this.setData({
total: 0,
todoList: []
})
}
else {
wx.showModal({
content: "已经到底啦!",
showCancel: false,
confirmText: "确定",
})
}
} else {
let list
if (page == 1) {
list = res.data.rows
} else {
list = this.data.todoList.concat(res.data.rows)
}
this.setData({
total: res.data.total,
todoList: list
})
}
}
wx.hideLoading();
}
});
},
getdoneList: function (page) {
var that = this;
if (page != 1) { page = that.data.page2 }
wx.showLoading({
title: '加载中',
}),
wx.request({
url: this.data.serverUrl + 'api/troublefollowtask?a=listdone&rows=10&page=' + page,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
if (res.statusCode === 200) {
if (res.data.rows.length == 0) {
if (page == 1) {
this.setData({
total: 0,
doneList: []
})
}
else {
wx.showModal({
content: "已经到底啦!",
showCancel: false,
confirmText: "确定",
})
}
} else {
let list
if (page == 1) {
list = res.data.rows
} else {
list = this.data.doneList.concat(res.data.rows)
}
this.setData({
total: res.data.total,
doneList: list
})
}
}
wx.hideLoading();
}
});
},
}) })

View File

@ -1,3 +1,5 @@
{ {
"usingComponents": {} "navigationBarTitleText": "隐患跟踪",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
} }

View File

@ -1,2 +1,67 @@
<!--pages/troublefollow/index.wxml--> <wxs src="../../wxs/subutil.wxs" module="tools" />
<text>pages/troublefollow/index.wxml</text> <view class="weui-tab">
<view class="weui-navbar">
<block wx:for="{{tabs}}" wx:key="*this">
<view id="{{index}}" class="weui-navbar__item {{activeIndex == index ? 'weui-bar__item_on' : ''}}" bindtap="tabClick">
<view class="weui-navbar__title">{{item}}</view>
</view>
</block>
<view class="weui-navbar__slider" style="left: {{sliderLeft}}px; transform: translateX({{sliderOffset}}px); -webkit-transform: translateX({{sliderOffset}}px);"></view>
</view>
<view class="weui-tab__panel">
<view class="weui-tab__content" hidden="{{activeIndex != 0}}">
<view class="head">共{{total}}条待执行任务</view>
<view class="weui-cells weui-cells_after-title">
<block wx:for="{{todoList}}" wx:key="unique">
<navigator url="handle?id={{item.id}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">
<span style="color:red;font-weight:bold">{{item.gridlevel__dickeyname}}</span>
{{item.trouble__yhnum}}
</view>
<view class="weui-media-box__desc">
{{tools.sub(item.trouble__yhms)}}
</view>
<view class="weui-media-box__desc">
任务开启:
<span style="color:darkblue">{{item.taskadd}}</span>
-任务过期:
<span style="color:darkblue">{{item.taskexpire}}</span>
</view>
</view>
</navigator>
</block>
</view>
</view>
<view class="weui-tab__content" hidden="{{activeIndex != 1}}">
<view class="head">已完成{{total}}条任务</view>
<view class="weui-cells weui-cells_after-title">
<block wx:for="{{doneList}}" wx:key="unique">
<navigator url="detail?id={{item.id}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">
<span wx:if="{{item.taskdo}}" style="background-color:green;color:white;padding:2px">已执行</span>
<span wx:else style="background-color:orange;color:white;padding:2px">未执行</span>
<span style="color:red;font-weight:bold;margin-left:2px">{{item.gridlevel__dickeyname}}</span>
{{item.trouble__yhnum}}
</view>
<view class="weui-media-box__desc">
{{tools.sub(item.trouble__yhms)}}
</view>
<view class="weui-media-box__desc" wx:if="{{item.taskdo}}">
执行时间:
<span style="color:darkblue">{{item.taskdo}}</span>
</view>
<view class="weui-media-box__desc">
任务开启:
<span style="color:darkblue">{{item.taskadd}}</span>
-任务过期:
<span style="color:darkblue">{{item.taskexpire}}</span>
</view>
</view>
</navigator>
</block>
</view>
</view>
</view>
</view>

View File

@ -1 +1,14 @@
/* pages/troublefollow/index.wxss */ .weui-btn{
width:auto;
margin: 5px;
}
.container {
background-color: #fff;
color: #939393;
}
.head{
color:#fff;
background-color: cornflowerblue;
text-align: center;
}

View File

@ -70,11 +70,21 @@ function formatSeconds(value) {
return result; return result;
} }
function toSubString(value) {
if (value.length>=14){
var str = value.substring(0, 14)
return str + "..."
} else {
return value
}
}
module.exports = { module.exports = {
getQueryString: getQueryString, getQueryString: getQueryString,
formatTime: formatTime, formatTime: formatTime,
formatTime2:formatTime2, formatTime2:formatTime2,
formatSeconds:formatSeconds, formatSeconds:formatSeconds,
toSubString: toSubString
} }

11
wxs/subutil.wxs Normal file
View File

@ -0,0 +1,11 @@
var sub = function(val) {
if (val.length == 0 || val == undefined) {
return;
}
if (val.length > 17) {
return val.substring(0, 17) + "...";
} else {
return val;
}
}
module.exports.sub = sub;