diff --git a/app.json b/app.json
index 9de8a63..56e16ee 100644
--- a/app.json
+++ b/app.json
@@ -63,7 +63,8 @@
"pages/risk/myindex",
"pages/risk/detail",
"pages/risktask/index",
- "pages/risktask/check"
+ "pages/risktask/check",
+ "pages/risktask/main"
],
"window": {
"backgroundTextStyle": "light",
diff --git a/pages/risktask/check.js b/pages/risktask/check.js
index 886af98..84555c8 100644
--- a/pages/risktask/check.js
+++ b/pages/risktask/check.js
@@ -17,10 +17,12 @@ Page({
console.log(options)
this.data.riskact = options.riskact
this.data.group = options.group
- this.getlist()
},
getlist:function(){
var page = this.data.page
+ wx.showLoading({
+ title: '加载中',
+ })
wx.request({
url: getApp().globalData.serverUrl + 'api/risktask?a=listtask&rows=10&page=' + page + '&group=' + this.data.group + '&riskact=' + this.data.riskact,
header: {
@@ -29,6 +31,7 @@ Page({
},
success: res => {
if (res.statusCode === 200) {
+ wx.hideLoading()
console.log(res.data)
if (res.data.rows.length == 0) {
if (page == 1) {
@@ -72,7 +75,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
-
+ this.getlist()
},
/**
@@ -108,5 +111,11 @@ Page({
*/
onShareAppMessage: function () {
- }
+ },
+ open: function (e) {
+ console.log(e)
+ wx.navigateTo({
+ url: '/pages/trouble/addtrouble?type=risktask&index=' + e.currentTarget.dataset.index,
+ })
+ },
})
\ No newline at end of file
diff --git a/pages/risktask/check.wxml b/pages/risktask/check.wxml
index 9554f7e..2f8f8cc 100644
--- a/pages/risktask/check.wxml
+++ b/pages/risktask/check.wxml
@@ -39,9 +39,11 @@
{{item.risk__measure5}}
无
- 确认已排查
-
+
+
+
+
diff --git a/pages/risktask/index.wxml b/pages/risktask/index.wxml
index 4619108..1c7db05 100644
--- a/pages/risktask/index.wxml
+++ b/pages/risktask/index.wxml
@@ -9,7 +9,7 @@
- 共{{donetotal}}条合理化建议
+ 共{{donetotal}}条已查
diff --git a/pages/risktask/main.js b/pages/risktask/main.js
new file mode 100644
index 0000000..7abd958
--- /dev/null
+++ b/pages/risktask/main.js
@@ -0,0 +1,283 @@
+// pages/examtest/main.js
+var util = require('../../utils/util.js')
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ fxIndex: 0,
+ answerChoices: [],
+ ydtm: 0
+ },
+ riskdata: {
+
+ },
+ calydtm: function (e) {
+ var tms = this.riskdata.tms
+ var ydtm = 0
+ for (var i = 0, len = tms.length; i < len; ++i) {
+ if (tms[i].userchecked && tms[i].userchecked.length != 0) {
+ ydtm += 1
+ }
+ }
+ this.setData({
+ ydtm: ydtm
+ })
+ },
+ radioChange: function (e) {
+ console.log('radio发生change事件,携带value值为:', e.detail.value);
+ var answerChoices = this.data.answerChoices;
+ for (var i = 0, len = answerChoices.length; i < len; ++i) {
+ answerChoices[i].checked = answerChoices[i].value == e.detail.value;
+ }
+
+ this.setData({
+ answerChoices: answerChoices,
+ });
+ this.riskdata.tms[this.data.fxIndex]['userchecked'] = e.detail.value
+ this.calydtm()
+ },
+ checkboxChange: function (e) {
+ console.log('checkbox发生change事件,携带value值为:', e.detail.value);
+
+ var answerChoices = this.data.answerChoices, values = e.detail.value;
+ for (var i = 0, lenI = answerChoices.length; i < lenI; ++i) {
+ answerChoices[i].checked = false;
+
+ for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
+ if (answerChoices[i].value == values[j]) {
+ answerChoices[i].checked = true;
+ break;
+ }
+ }
+ }
+
+ this.setData({
+ answerChoices: answerChoices,
+ });
+ this.riskdata.tms[this.data.fxIndex]['userchecked'] = e.detail.value
+ this.calydtm()
+ },
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ console.log(options)
+ this.data.riskact = options.riskact
+ this.data.group = options.group
+ wx.showLoading({})
+ wx.request({
+ url: getApp().globalData.serverUrl + 'api/risktask?a=listtaskall' + '&group=' + this.data.group + '&riskact=' + this.data.riskact,
+ header: {
+ 'content-type': 'application/json', // 默认值
+ 'Cookie': wx.getStorageSync("sessionid"),
+ },
+ success: res => {
+ if (res.statusCode === 200) {
+ let risks = res.data
+ this.riskdata = risks
+ this.showRisk(0)
+ this.setData({
+ total: risks.total,
+ })
+ }
+ wx.hideLoading();
+ }
+ });
+
+
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+ // wx.showModal({
+ // title: '系统提示',
+ // content: '未完成答卷,是否要提交答卷!',
+ // confirmText: "提交",
+ // cancelText: "点错了",
+ // success: function (res) {
+ // if (res.confirm) {
+ // } else {
+ // this.onShow()
+ // }
+ // }
+ // })
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ },
+ showRisk: function (index) {
+ var that = this
+ var currentFx = that.riskdata.rows[index]
+ console.log(currentFx)
+ that.setData({ 'currentFx': currentFx })
+ },
+ showChecked: function (index) {
+ var tm = this.riskdata.tms[index]
+ let choices = this.data.answerChoices
+ if (tm.userchecked) {
+ if (tm.question__type == 2) {
+ for (var i = 0, len = choices.length; i < len; i++) {
+ if (tm.userchecked.indexOf(choices[i].value) != -1) {
+ choices[i].checked = true
+ }
+ }
+ } else {
+ for (var i = 0, len = choices.length; i < len; i++) {
+ if (choices[i].value == tm.userchecked) {
+ choices[i].checked = true
+ }
+ }
+ }
+ this.setData({
+ answerChoices: choices
+ })
+ }
+ },
+ next: function () {
+ var that = this
+ var fxIndex = that.data.fxIndex + 1
+ that.showTm(fxIndex)
+ that.setData({
+ fxIndex: fxIndex,
+ })
+ that.showChecked(fxIndex)
+ },
+ previous: function () {
+ var that = this
+ var fxIndex = that.data.fxIndex - 1
+ that.showTm(fxIndex)
+ that.setData({
+ fxIndex: fxIndex,
+ })
+ that.showChecked(fxIndex)
+ },
+ hand: function () {
+ var that = this
+ if (that.data.ydtm < that.riskdata.tms.length) {
+ wx.showModal({
+ title: '警告',
+ content: '答卷未完成,确定提交?',
+ confirmText: "确定",
+ cancelText: "取消",
+ success: function (res) {
+ if (res.confirm) {
+ that.handtest()
+ }
+ }
+ })
+ } else {
+ wx.showModal({
+ content: '确定提交?',
+ confirmText: "确定",
+ cancelText: "取消",
+ success: function (res) {
+ if (res.confirm) {
+ that.handtest()
+ }
+ }
+ })
+ }
+ },
+ handtest: function () {
+ var data = {
+ 'testid': this.data.testid,
+ 'starttime': this.data.starttime,
+ 'endtime': util.formatTime(new Date()),
+ 'sheet': this.riskdata.tms
+ }
+ wx.showLoading({
+ title: '自动判卷中..',
+ })
+ wx.request({
+ url: getApp().globalData.serverUrl + 'api/examtestdetail?a=handtest&id=' + this.data.testid,
+ header: {
+ 'content-type': 'application/json', // 默认值
+ 'Cookie': wx.getStorageSync("sessionid"),
+ },
+ method: 'POST',
+ data: data,
+ success: res => {
+ if (res.statusCode === 200) {
+ wx.hideLoading()
+ wx.redirectTo({
+ url: 'result?' + parseParams(res.data.data),
+ })
+ clearTimeout(getApp().globalData.timepass)
+ }
+ }
+ });
+ }
+})
+function formatmil(mil) {
+ var allSecond = Math.floor(mil / 1000);
+ var h = Math.floor(allSecond / 3600);
+ var m = Math.floor((allSecond - h * 3600) / 60);
+ var s = Math.floor(allSecond - h * 3600 - m * 60);
+ h = toTow(h);
+ m = toTow(m);
+ s = toTow(s);
+ return h + ":" + m + ":" + s;
+}
+function toTow(num) {
+ if (num < 10) {
+ return "0" + num;
+ } else {
+ return num;
+ }
+}
+function parseParams(data) {
+ try {
+ var tempArr = [];
+ for (var i in data) {
+ var key = encodeURIComponent(i);
+ var value = encodeURIComponent(data[i]);
+ tempArr.push(key + '=' + value);
+ }
+ var urlParamsStr = tempArr.join('&');
+ return urlParamsStr;
+ } catch (err) {
+ return '';
+ }
+}
\ No newline at end of file
diff --git a/pages/risktask/main.json b/pages/risktask/main.json
new file mode 100644
index 0000000..9c848e5
--- /dev/null
+++ b/pages/risktask/main.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {},
+ "navigationBarTitleText": "考试中"
+}
\ No newline at end of file
diff --git a/pages/risktask/main.wxml b/pages/risktask/main.wxml
new file mode 100644
index 0000000..809eb2d
--- /dev/null
+++ b/pages/risktask/main.wxml
@@ -0,0 +1,50 @@
+
+
+
+倒计时 {{countdown}}
+
+答题卡: {{ydtm}}/{{tmtotal}}
+
+
+
+
+
+ {{tmIndex+1}}.
+ 单选题
+ 多选题
+ 判断题
+ ({{currentTm.score}}分)
+
+ {{currentTm.question__title}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/risktask/main.wxss b/pages/risktask/main.wxss
new file mode 100644
index 0000000..e51debe
--- /dev/null
+++ b/pages/risktask/main.wxss
@@ -0,0 +1,18 @@
+.head{
+ color:#fff;
+ background-color: cornflowerblue;
+}
+.txlabel{
+ color:#fff;
+ background-color: rgb(216, 140, 0);
+ padding: 2px
+}
+.weui-btn{
+ width:auto;
+ margin: 5px;
+}
+.sheet{
+ color:#fff;
+ background-color: red;
+ float:right
+}
\ No newline at end of file
diff --git a/pages/trouble/addtrouble.js b/pages/trouble/addtrouble.js
index 9b63885..a23e164 100644
--- a/pages/trouble/addtrouble.js
+++ b/pages/trouble/addtrouble.js
@@ -258,7 +258,30 @@ Page({
}
}
});
+ }else if (this.data.yhtype == 'risktask') {
+ let data = {}
+ data.risktask = this.data.risktaskdata.id
+ data.trouble = res.data.trouble
+ wx.request({
+ url: this.data.serverUrl + 'api/risktask?a=checktrouble',
+ header: {
+ 'content-type': 'application/json', //
+ 'Cookie': wx.getStorageSync("sessionid"),
+ },
+ method: 'POST',
+ data: data,
+ success: res => {
+ if (res.statusCode === 200) {
+ wx.hideLoading();
+ wx.navigateBack({
+ delta: 2
+ })
+
+ }
+ }
+ });
}else{
+ console.log(x)
wx.hideLoading();
wx.navigateBack()
}
@@ -329,7 +352,6 @@ Page({
mapright: false
})
}
- console.log(options.type)
if(options.type=='inspect'){
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2];
@@ -344,6 +366,20 @@ Page({
equipmentname: inspectdata.equipment.name,
})
}
+ else if (options.type == 'risktask'){
+ var pages = getCurrentPages();
+ var prevPage = pages[pages.length - 2];
+ var risktaskdata = prevPage.data.alllist[options.index]
+ console.log(risktaskdata)
+ this.data.risktaskdata = risktaskdata
+ this.setData({
+ yhtype: 'risktask',
+ yhqy: risktaskdata.risk__riskact__area__id,
+ yhqy__name: risktaskdata.risk__riskact__area__name,
+ yhdd: risktaskdata.risk__riskact__place,
+ riskstep: risktaskdata.risk__step,
+ })
+ }
},
/**
diff --git a/pages/trouble/addtrouble.wxml b/pages/trouble/addtrouble.wxml
index fb90b6c..d7ccedc 100644
--- a/pages/trouble/addtrouble.wxml
+++ b/pages/trouble/addtrouble.wxml
@@ -2,6 +2,7 @@
错误提示
{{equipmentname}} 设备异常
+ 风险 {{riskstep}}
隐患图片