|
@@ -6,6 +6,7 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
images: [],
|
|
|
+ signs: [],
|
|
|
worksheetinfo: {},
|
|
|
chargstations: [],
|
|
|
chargstationsindex: 0,
|
|
@@ -25,10 +26,12 @@ Page({
|
|
|
}, {
|
|
|
value: 5,
|
|
|
text: '进行中'
|
|
|
- }, {
|
|
|
- value: 6,
|
|
|
- text: '已完成'
|
|
|
- }, {
|
|
|
+ }
|
|
|
+ // , {
|
|
|
+ // value: 6,
|
|
|
+ // text: '已完成'
|
|
|
+ // }
|
|
|
+ , {
|
|
|
value: 7,
|
|
|
text: '完成确认'
|
|
|
}],
|
|
@@ -41,10 +44,27 @@ Page({
|
|
|
text: '工程实施'
|
|
|
}],
|
|
|
workBigclassindex: 0,
|
|
|
- exceptdate: '0000-00-00',
|
|
|
- excepttime: '00:00',
|
|
|
- finishdate: '0000-00-00',
|
|
|
- finishtime: '00:00',
|
|
|
+ breakdownType: [{
|
|
|
+ value: 1,
|
|
|
+ text: '车辆导致'
|
|
|
+ }, {
|
|
|
+ value: 2,
|
|
|
+ text: '桩体导致'
|
|
|
+ }, {
|
|
|
+ value: 3,
|
|
|
+ text: '人为导致'
|
|
|
+ }, {
|
|
|
+ value: 4,
|
|
|
+ text: '基础设施问题'
|
|
|
+ }, {
|
|
|
+ value: 5,
|
|
|
+ text: '其他'
|
|
|
+ }],
|
|
|
+ breakdownTypeindex: null,
|
|
|
+ exceptdate: null,
|
|
|
+ excepttime: null,
|
|
|
+ finishdate: null,
|
|
|
+ finishtime: null,
|
|
|
accendantids: []
|
|
|
},
|
|
|
bindChargstationsChange: function(e) {
|
|
@@ -81,6 +101,16 @@ Page({
|
|
|
worksheetinfo
|
|
|
});
|
|
|
},
|
|
|
+ bindBreakdownType(e) {
|
|
|
+ //console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
|
+ let breakdownType = this.data.breakdownType[e.detail.value].value;
|
|
|
+ let worksheetinfo = this.data.worksheetinfo;
|
|
|
+ worksheetinfo.breakdownType = breakdownType;
|
|
|
+ this.setData({
|
|
|
+ breakdownTypeindex: e.detail.value,
|
|
|
+ worksheetinfo
|
|
|
+ });
|
|
|
+ },
|
|
|
bindAccendantChange: function(e) {
|
|
|
let chargstationid = this.data.chargstations[this.data.chargstationsindex].id;
|
|
|
let accendant = this.data.worksheetinfo.accendant;
|
|
@@ -129,37 +159,38 @@ Page({
|
|
|
let worksheetinfo = this.data.worksheetinfo;
|
|
|
worksheetinfo.pams = this.data.accendantids;
|
|
|
worksheetinfo.accendant = null;
|
|
|
- worksheetinfo.exceptTime = this.data.exceptdate + " " + this.data.excepttime + ":00";
|
|
|
- worksheetinfo.finishTime = this.data.finishdate + " " + this.data.finishtime + ":00";
|
|
|
-
|
|
|
+ if (this.data.exceptdate && this.data.excepttime) {
|
|
|
+ worksheetinfo.exceptTime = this.data.exceptdate + " " + this.data.excepttime + ":00";
|
|
|
+ }
|
|
|
+ if (this.data.finishdate && this.data.finishtime){
|
|
|
+ worksheetinfo.finishTime = this.data.finishdate + " " + this.data.finishtime + ":00";
|
|
|
+ }
|
|
|
let images = this.data.images;
|
|
|
- if (images.length == 0) {
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechat/editWorkSheet',
|
|
|
- data: worksheetinfo,
|
|
|
- method: 'POST',
|
|
|
- success(res) {
|
|
|
- //console.log(res);
|
|
|
- if (res.data.code == 500) {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: res.data.msg
|
|
|
- });
|
|
|
- } else {
|
|
|
- wx.navigateBack();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- var imgString = [];
|
|
|
-
|
|
|
- function uploadFile() {
|
|
|
+ var imgString = [];
|
|
|
+
|
|
|
+ var pciString = [];
|
|
|
+ this.data.pcitures.forEach((item, index) =>{
|
|
|
+ pciString.push(item.src);
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
- images.forEach((item, index) => {
|
|
|
+ let signs = this.data.signs;
|
|
|
+ console.log(signs.length == 0);
|
|
|
+ var signString = [];
|
|
|
+ if (signs.length == 0) {
|
|
|
+ //2021-1-1撤销校验
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '请设置签名',
|
|
|
+ // icon: 'loading',
|
|
|
+ // duration: 2000,
|
|
|
+ // mask: true,
|
|
|
+ // success: function() {}
|
|
|
+ // });
|
|
|
+ // return;
|
|
|
+ } else {
|
|
|
+ signs.forEach((item, index) => {
|
|
|
wx.uploadFile({
|
|
|
- url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechat/editWorkSheetImg',
|
|
|
- filePath: images[index],
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/editWorkSheetImg',
|
|
|
+ filePath: signs[index],
|
|
|
name: 'imageFileName',
|
|
|
success: function(res) {
|
|
|
let result = JSON.parse(res.data);
|
|
@@ -169,57 +200,117 @@ Page({
|
|
|
content: result.msg
|
|
|
});
|
|
|
} else {
|
|
|
- imgString.push(result.msg);
|
|
|
- console.log(imgString);
|
|
|
- if (index == (images.length - 1)) {
|
|
|
-
|
|
|
- var uploadImgOverFlag = setInterval(function() {
|
|
|
- if (imgString.length == images.length) {
|
|
|
- clearInterval(uploadImgOverFlag);
|
|
|
- worksheetinfo.pciture = imgString.join(",");
|
|
|
- wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechat/editWorkSheet',
|
|
|
- data: worksheetinfo,
|
|
|
- method: 'POST',
|
|
|
- success(res) {
|
|
|
- //console.log(res);
|
|
|
- if (res.data.code == 500) {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: res.data.msg
|
|
|
- });
|
|
|
- } else {
|
|
|
- wx.navigateBack();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }, 100);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+ signString.push(result.msg);
|
|
|
+ console.log(signString);
|
|
|
}
|
|
|
- },
|
|
|
- fail: function(data) {
|
|
|
- console.log(data);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
+ var uploadSignOverFlag = setInterval(function() {
|
|
|
+ if (signString.length == signs.length) {
|
|
|
+ clearInterval(uploadSignOverFlag);
|
|
|
+ if (images.length == 0) {
|
|
|
+ if (worksheetinfo.pciture) {
|
|
|
+ console.log(worksheetinfo.pciture);
|
|
|
+ worksheetinfo.pciture = (pciString.concat(imgString).concat(signString)).join(",");
|
|
|
+ //worksheetinfo.pciture = ((worksheetinfo.pciture.split(",")).concat(signString)).join(",");
|
|
|
+ console.log(worksheetinfo.pciture);
|
|
|
+ }
|
|
|
+ wx.request({
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/editWorkSheet',
|
|
|
+ data: worksheetinfo,
|
|
|
+ method: 'POST',
|
|
|
+ success(res) {
|
|
|
+ //console.log(res);
|
|
|
+ if (res.data.code == 500) {
|
|
|
+ wx.showModal({
|
|
|
+ showCancel: false,
|
|
|
+ content: res.data.msg
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ wx.navigateBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+
|
|
|
+ images.forEach((item, index) => {
|
|
|
+ wx.uploadFile({
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/editWorkSheetImg',
|
|
|
+ filePath: images[index],
|
|
|
+ name: 'imageFileName',
|
|
|
+ success: function(res) {
|
|
|
+ let result = JSON.parse(res.data);
|
|
|
+ if (result.code == 500) {
|
|
|
+ wx.showModal({
|
|
|
+ showCancel: false,
|
|
|
+ content: result.msg
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ imgString.push(result.msg);
|
|
|
+ console.log(imgString);
|
|
|
+ if (index == (images.length - 1)) {
|
|
|
+ var uploadImgOverFlag = setInterval(function() {
|
|
|
+ if (imgString.length == images.length) {
|
|
|
+ clearInterval(uploadImgOverFlag);
|
|
|
+ //worksheetinfo.pciture = ((worksheetinfo.pciture.split(",")).concat(signString)).join(",");
|
|
|
+ worksheetinfo.pciture = (pciString.concat(imgString).concat(signString)).join(",");
|
|
|
+ //var images = this.data.images.concat(res.tempFilePaths);
|
|
|
+ wx.request({
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/editWorkSheet',
|
|
|
+ data: worksheetinfo,
|
|
|
+ method: 'POST',
|
|
|
+ success(res) {
|
|
|
+ //console.log(res);
|
|
|
+ if (res.data.code == 500) {
|
|
|
+ wx.showModal({
|
|
|
+ showCancel: false,
|
|
|
+ content: res.data.msg
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ wx.navigateBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function(data) {
|
|
|
+ console.log(data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }, 100);
|
|
|
+
|
|
|
|
|
|
},
|
|
|
openImage(e) {
|
|
|
+ //var that = this;
|
|
|
+ var imgCount = (9 - this.data.pcitures.length) < 0 ? 0 : 9 - this.data.pcitures.length;
|
|
|
+ console.log(imgCount);
|
|
|
wx.chooseImage({
|
|
|
- count: 5,
|
|
|
+ count: 9 - (this.data.pcitures.length + this.data.images.length),
|
|
|
//sizeType: ['original', 'compressed'], //可选择原图或压缩后的图片
|
|
|
//sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
|
|
|
success: res => {
|
|
|
+ //console.log(res);
|
|
|
var images = this.data.images.concat(res.tempFilePaths);
|
|
|
// 限制最多只能留下5张照片
|
|
|
- images = images.length <= 5 ? images : images.slice(0, 5);
|
|
|
+ images = images.length <= imgCount ? images : images.slice(0, imgCount);
|
|
|
+ if (images.length >= imgCount || imgCount<= 0){
|
|
|
+ wx.showToast({
|
|
|
+ title: '最多9张图片',
|
|
|
+ icon:'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- pcitures: [],
|
|
|
+ //pcitures: [],
|
|
|
images
|
|
|
});
|
|
|
}
|
|
@@ -235,14 +326,47 @@ Page({
|
|
|
images
|
|
|
});
|
|
|
},
|
|
|
+ removePciture(e) {
|
|
|
+ //console.log(e);
|
|
|
+ //console.log(this.data.images);
|
|
|
+
|
|
|
+ let idx = e.currentTarget.dataset.idx;
|
|
|
+ var pcitures = this.data.pcitures;
|
|
|
+ pcitures.splice(idx, 1);
|
|
|
+ this.setData({
|
|
|
+ pcitures
|
|
|
+ });
|
|
|
+ },
|
|
|
+ removeSign(e) {
|
|
|
+ //console.log(e);
|
|
|
+ //console.log(this.data.images);
|
|
|
+ let idx = e.currentTarget.dataset.idx;
|
|
|
+ var signs = this.data.signs;
|
|
|
+ signs.splice(idx, 1);
|
|
|
+ this.setData({
|
|
|
+ signs
|
|
|
+ });
|
|
|
+ },
|
|
|
handleImagePreview(e) {
|
|
|
const idx = e.target.dataset.idx
|
|
|
const images = this.data.images
|
|
|
+
|
|
|
wx.previewImage({
|
|
|
current: images[idx], //当前预览的图片
|
|
|
urls: images, //所有要预览的图片
|
|
|
})
|
|
|
},
|
|
|
+ handleSignPreview(e) {
|
|
|
+ const idx = e.target.dataset.idx
|
|
|
+ const signs = this.data.signs
|
|
|
+ //console.log(idx);
|
|
|
+ //console.log(signs);
|
|
|
+ //console.log(signs[idx]);
|
|
|
+ wx.previewImage({
|
|
|
+ current: signs[idx], //当前预览的图片
|
|
|
+ urls: signs, //所有要预览的图片
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
@@ -254,6 +378,7 @@ Page({
|
|
|
} = options;
|
|
|
//console.log(worksheet);
|
|
|
let worksheetinfo = JSON.parse(worksheet);
|
|
|
+ //worksheetinfo.breakdownType = 2;
|
|
|
this.setData({
|
|
|
worksheetinfo
|
|
|
});
|
|
@@ -285,9 +410,21 @@ Page({
|
|
|
finishtime: datetime[1].substr(0, 5)
|
|
|
});
|
|
|
}
|
|
|
+ this.data.breakdownType.forEach((item, index) => {
|
|
|
+ if (item.value == worksheetinfo.breakdownType) {
|
|
|
+ this.setData({
|
|
|
+ breakdownTypeindex: index
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
if (worksheetinfo.pciture) {
|
|
|
- let pcitures = worksheetinfo.pciture.split(",");
|
|
|
+ let pcitures_src = worksheetinfo.pciture.split(",");
|
|
|
+ var pcitures = [];
|
|
|
+ pcitures_src.forEach((item, index) => {
|
|
|
+ pcitures[index] = { src: item, flag: item.indexOf('https://cdgl.pjnes.com/profile/station/') != -1};
|
|
|
+ });
|
|
|
this.setData({
|
|
|
pcitures
|
|
|
});
|
|
@@ -309,7 +446,7 @@ Page({
|
|
|
longitude,
|
|
|
} = res;
|
|
|
wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechat/userChargStations',
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/userChargStations',
|
|
|
data: {
|
|
|
userId: userInfo.userId,
|
|
|
lat: latitude,
|
|
@@ -337,7 +474,7 @@ Page({
|
|
|
});
|
|
|
}
|
|
|
wx.request({
|
|
|
- url: getApp().globalData.postHeadAgreement +'://cdgl.xinyhy.cn/restapi/wechat/getuserworksheet',
|
|
|
+ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/getuserworksheet',
|
|
|
data: worksheetinfo.id,
|
|
|
method: 'POST',
|
|
|
success(res) {
|
|
@@ -352,7 +489,13 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ openSign(e) {
|
|
|
+ let url = `/pages/sign/sign`;
|
|
|
+ wx.navigateTo({
|
|
|
+ url
|
|
|
+ });
|
|
|
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|