// pages/fireSafetymeasure/fireSafetymeasure.js
|
var req_url = getApp().globalData.base_url;
|
const app = getApp()
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
locknum:0,
|
firesafetymeasure:'',
|
opinion: '',
|
bumen: '',
|
zypcode:'',
|
username : wx.getStorageSync('username'),
|
phone : wx.getStorageSync('phone'),
|
safetyMeasure: [
|
{
|
context: "作业前,制定交通组织方案,并已通知相关部门或单位",
|
safetymeasure: '',
|
refer: "",
|
name:'',
|
phone:'',
|
lock:true,
|
},
|
{
|
context: "作业前,在断路的路口和相关道路上设置交通警示标志,在作业区域附近设置路栏、道路作业警示灯、导向标等交通警示设施",
|
safetymeasure: '',
|
refer: "",
|
name:'',
|
phone:'',
|
lock:true,
|
},
|
{
|
context: "夜间作业设置警示灯",
|
safetymeasure: '',
|
refer: "",
|
name:'',
|
phone:'',
|
lock:true,
|
},
|
{
|
context: "",
|
safetymeasure: '',
|
refer: "",
|
name:'',
|
phone:'',
|
lock:true,
|
},
|
],
|
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad(options) {
|
console.log(options);
|
this.setData({
|
firesafetymeasure:options.safetymeasure,
|
opinion: options.opinion,
|
bumen: options.bumen,
|
zypcode:options.zypcode
|
})
|
this.getList();
|
},
|
getList: function () {
|
var that = this;
|
console.log(that.data.zypcode);
|
//请求后台数据
|
wx.request({
|
url: req_url + "/findCircuitCode",
|
data: {
|
code: that.data.zypcode,
|
},
|
method: 'get',
|
success: function (res) {
|
|
console.log(res);
|
var datas = res.data;
|
if (res.statusCode != 200) {
|
wx.showToast({
|
title: '获取数据失败',
|
icon: 'none',
|
duration: 2000
|
});
|
} else {
|
var zypd = []
|
var json = {}
|
json.context = that.data.safetyMeasure[0].context
|
json.refer = datas.refer1
|
json.safetymeasure = datas.safetymeasure1
|
json.name = datas.safetymeasure1.split(',')[0]
|
json.phone = datas.safetymeasure1.split(',')[1]
|
if (wx.getStorageSync('username')==datas.safetymeasure1.split(',')[0]&&wx.getStorageSync('phone')==datas.safetymeasure1.split(',')[1]) {
|
console.log(11111);
|
json.lock=false
|
}else{
|
that.setData({
|
locknum:that.data.locknum+1
|
})
|
json.lock=true
|
}
|
zypd.push(json)
|
var json1 = {}
|
json1.context = that.data.safetyMeasure[1].context
|
json1.refer = datas.refer2
|
json1.safetymeasure = datas.safetymeasure2
|
json1.name = datas.safetymeasure2.split(',')[0]
|
json1.phone = datas.safetymeasure2.split(',')[1]
|
if (wx.getStorageSync('username')==datas.safetymeasure2.split(',')[0]&&wx.getStorageSync('phone')==datas.safetymeasure2.split(',')[1]) {
|
|
json1.lock=false
|
}else{
|
that.setData({
|
locknum:that.data.locknum+1
|
})
|
json1.lock=true
|
}
|
zypd.push(json1)
|
if (datas.safetymeasureother!='') {
|
var json2 = {}
|
json2.context = that.data.safetyMeasure[2].context
|
json2.refer = datas.refer3
|
json2.safetymeasure = datas.safetymeasure3
|
json2.name = datas.safetymeasure3.split(',')[0]
|
json2.phone = datas.safetymeasure3.split(',')[1]
|
if (wx.getStorageSync('username')==datas.safetymeasure3.split(',')[0]&&wx.getStorageSync('phone')==datas.safetymeasure3.split(',')[1]) {
|
|
json2.lock=false
|
}else{
|
that.setData({
|
locknum:that.data.locknum+1
|
})
|
json2.lock=true
|
}
|
zypd.push(json2)
|
}else{
|
var json2 = {}
|
json2.context =''
|
json2.refer = ''
|
json2.safetymeasure = ''
|
json2.name = ''
|
json2.phone = ''
|
that.setData({
|
locknum:that.data.locknum+1
|
})
|
json2.lock=true
|
zypd.push(json2)
|
}
|
var fenxian = []
|
that.setData({
|
safetyMeasure: zypd,
|
})
|
}
|
}
|
})
|
},
|
onChange(event) {
|
var that = this;
|
var zypd = []
|
var json = {}
|
json.context = that.data.safetyMeasure[0].context
|
json.refer = that.data.safetyMeasure[0].refer
|
json.lock = that.data.safetyMeasure[0].lock
|
if (event.currentTarget.dataset.index==0) {
|
|
json.refer = event.detail
|
}
|
zypd.push(json)
|
var json1 = {}
|
json1.context = that.data.safetyMeasure[1].context
|
json1.refer = that.data.safetyMeasure[1].refer
|
json1.lock = that.data.safetyMeasure[1].lock
|
if (event.currentTarget.dataset.index==1) {
|
json1.refer =event.detail
|
}
|
zypd.push(json1)
|
var json2 = {}
|
json2.context = that.data.safetyMeasure[2].context
|
json2.refer = that.data.safetyMeasure[2].refer
|
json2.lock = that.data.safetyMeasure[2].lock
|
if (event.currentTarget.dataset.index==2) {
|
json2.refer = event.detail
|
}
|
zypd.push(json2)
|
|
|
var fenxian = []
|
that.setData({
|
safetyMeasure: zypd,
|
})
|
|
var fenxian = []
|
that.setData({
|
safetyMeasure: zypd,
|
})
|
// this.setData({
|
// safetyMeasure[1].refer: event.detail,
|
// });
|
},
|
showBack() {
|
wx.navigateBack({
|
delta: 1
|
})
|
},
|
showPopup() {
|
var that = this;
|
var json = {}
|
|
json.code= that.data.zypcode,
|
json.refer1= that.data.safetyMeasure[0].refer,
|
json.refer2= that.data.safetyMeasure[1].refer,
|
json.refer3= that.data.safetyMeasure[2].refer,
|
|
|
wx.navigateTo({
|
url: '../safetyMeasureSign/safetyMeasureSign?opinion=' + that.data.opinion + '&bumen=' + that.data.bumen + '&name=' + that.data.zypcode+ '&url=/updateGround'+ '&refer=' + json
|
})
|
|
},
|
submitForm: function (e) {
|
var that = this;
|
console.log(that.data.zypcode);
|
console.log(that.data.safetyMeasure[1].refer);
|
wx.request({
|
url: req_url + "/updateCircuit",
|
method: 'post',
|
data: {
|
code: that.data.zypcode,
|
refer1: that.data.safetyMeasure[0].refer,
|
refer2: that.data.safetyMeasure[1].refer,
|
refer3: that.data.safetyMeasure[2].refer,
|
|
},
|
header: {
|
'Content-Type': 'application/json'
|
},
|
success: (res) => {
|
if (res.errMsg == "request:ok") {
|
wx.showToast({
|
title: '操作成功',
|
icon: 'success',
|
duration: 2000
|
});
|
wx.navigateBack({
|
delta: 1
|
})
|
} else {
|
wx.showToast({
|
title: '操作失败',
|
})
|
}
|
}
|
// })
|
});
|
},
|
|
uploadPerPic(url, back) {
|
var name = ''
|
var that=this
|
name = 'sign'+that.data.zypcode+ wx.getStorageSync('phone');
|
wx.uploadFile({
|
url: req_url + "addsafetyMeasurepic",
|
method: "POST",
|
filePath: url,
|
name: 'file',
|
formData: {
|
'opinion': that.data.opinion,
|
'bumen': that.data.bumen,
|
'name': name,
|
},
|
success(res) {
|
console.log(res);
|
back(res.data);
|
},
|
fail(e) { }
|
})
|
},
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow() {
|
console.log(this.data.signtempFilePaths);
|
if (this.data.signtempFilePaths!='') {
|
var that = this;
|
that.uploadPerPic(this.data.signtempFilePaths, function back(resp) {
|
wx.request({
|
url: req_url + "/updateCircuit",
|
method: 'post',
|
data: {
|
username:wx.getStorageSync('username'),
|
phone:wx.getStorageSync('phone'),
|
sign: resp,
|
code: that.data.zypcode,
|
refer1: that.data.safetyMeasure[0].refer,
|
refer2: that.data.safetyMeasure[1].refer,
|
refer3: that.data.safetyMeasure[2].refer,
|
|
},
|
header: {
|
'Content-Type': 'application/json'
|
},
|
success: (res) => {
|
if (res.errMsg == "request:ok") {
|
var content = "用户:" + wx.getStorageSync('username') + "提交安全措施确认"
|
wx.request({
|
url: req_url + "/addZypLog",
|
method: 'post',
|
data: {
|
name: wx.getStorageSync('username'),
|
zyptype: "断路安全作业",
|
// bumen: that.data.bumen,
|
zypcode: that.data.zypcode,
|
content: content,
|
},
|
header: {
|
'Content-Type': 'application/json'
|
},
|
success: (res) => {
|
console.log(res);
|
|
}
|
});
|
wx.showToast({
|
title: '操作成功',
|
icon: 'success',
|
duration: 2000
|
});
|
wx.navigateBack({
|
delta: 1
|
})
|
} else {
|
wx.showToast({
|
title: '操作失败',
|
})
|
}
|
}
|
// })
|
});
|
})
|
}
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload() {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh() {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom() {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage() {
|
|
}
|
})
|