var Constant = require('../../utils/constant.js');
|
|
var app = getApp();
|
import Request from "../../utils/api"
|
Page({
|
|
data: {
|
//维修记录数据
|
taskFileList: [],
|
//报修图片
|
requestImagesList: [],
|
|
currentCorpID: 1,
|
currentEmployeeID: 1, //当前用户ID
|
|
requestFormId: 0,
|
taskFormId: 0,
|
logicID:0,
|
taskFormIsStop: false, //是否是暂停状态
|
currentBlankID: 0,
|
isTtaskFileListLoad: false,
|
|
taskFormStatusName: "",
|
stepFormStatusName: "工作中",
|
confirmDlgTitle: "信息",
|
tapConfirmCb: "tapConfirmStop", //点击确定,进行的按钮操作类型
|
tapToggleTaskIcon: "icon-off",
|
|
formEntity: {},
|
|
taskLogList: [], //时间轴数据
|
tabBar: {
|
"selectedColor": "#5DBCFF",
|
"normalColor": "#333",
|
"backgroundColor": "#fff",
|
"selectedBackgroundColor": "#fff",
|
"list": [{
|
"pagePath": "market/index/index",
|
"iconPath": "icon-jilu",
|
"selectedIconPath": "icon-jilu blue",
|
"text": "报修资料"
|
}, {
|
"pagePath": "tools/index/index",
|
"iconPath": "icon-xiangqing",
|
"selectedIconPath": "icon-xiangqing blue",
|
"text": "维修记录"
|
}, {
|
"pagePath": "viewing/index/index",
|
"iconPath": "icon-jilu2",
|
"selectedIconPath": "icon-jilu2 blue",
|
"text": "操作日志"
|
}]
|
},
|
floatMenu: {
|
animation: '',
|
bindtaps: "expand_floatMenu"
|
},
|
|
activeIndex: 0,
|
sliderOffset: 0,
|
|
longitude: 0, //经纬度
|
latitude: 0,
|
userLocAddress: "", //定位的地址(可能不是报修地址)
|
|
isShowConfirmDlg: false,
|
operateNote: '' //信息
|
},
|
|
//
|
onLoad: function (options) {
|
// console.log("options",options);
|
// console.log(options.requestformid,73)
|
var that = this;
|
var userInfo = app.globalData.userInfo;
|
if (userInfo) {
|
this.setData({
|
currentCorpID: userInfo.CorpID,
|
currentEmployeeID: userInfo.EmployeeID
|
});
|
} else {
|
wx.navigateTo({
|
url: '/login/login/index',
|
});
|
}
|
|
if (options.requestformid == '' || options.requestformid == undefined)
|
return;
|
if (options.taskformid == '' || options.taskformid == undefined)
|
return;
|
var requestformid = options.requestformid;
|
var taskformid = options.taskformid;
|
this.setData({
|
requestFormId: requestformid,
|
taskFormId: taskformid
|
});
|
|
//
|
this.initialTabbar();
|
|
//获取当前经纬度
|
setTimeout(function () {
|
that.getCurrentLocation();
|
}, 1000);
|
|
//初始化表单信息
|
this.intialFormInfo();
|
},
|
//初始化表单信息
|
intialFormInfo: function () {
|
|
var that = this;
|
var requestformid = this.data.requestFormId;
|
var taskformid = this.data.taskFormId;
|
//
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/Task/Form/Std/GetProgressDetailByID@V1.0",
|
method: 'GET',
|
data: {
|
|
ID: requestformid,
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
//
|
var result = res.data;
|
// console.log("taskdetail:",result);
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.message,
|
});
|
return;
|
}
|
var formEntity = result.Data.RequestForm;
|
//console.log(formEntity)
|
|
var imagesList = [];
|
if (formEntity.FileList != null && formEntity.FileList.length > 0) {
|
for (var i = 0; i < formEntity.FileList.length; i++) {
|
var big_image_name = Constant.BASE_SERVER_URL + formEntity.FileList[i].StorageUrl;
|
|
var m = {};
|
m.OriginPath = big_image_name;
|
m.ThumbPath = big_image_name;
|
imagesList.push(m);
|
}
|
}
|
|
|
that.setData({
|
formEntity: formEntity,
|
taskLogList: result.Data,
|
requestImagesList: imagesList,
|
taskFormStatusName: "维修中"
|
});
|
|
if (result.Data.FormStatus == 40 || result.Data.FormStatus == 42) {
|
that.setData({
|
taskFormIsStop: false, //是否是暂停状态
|
tapToggleTaskIcon: "icon-off",
|
currentBlankID: 0,
|
taskFormStatusName: "维修中...",
|
stepFormStatusName: "",
|
stepFormStatusName: "开工"
|
});
|
} else {
|
that.setData({
|
taskFormIsStop: true, //是否是暂停状态
|
tapToggleTaskIcon: "icon-on",
|
currentBlankID: formEntity.CurrentBlankID,
|
taskFormStatusName: "维修暂停...",
|
stepFormStatusName: "停工"
|
});
|
}
|
|
|
|
}
|
});
|
},
|
|
//加载定位
|
getCurrentLocation: function () {
|
var that = this;
|
wx.getLocation({
|
type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
success(resLoc) {
|
//console.log("getCurrentLocation", resLoc);
|
if (resLoc.longitude == 0 || resLoc.latitude == 0) { //当前位置信号较弱,请换个位置尝试
|
return;
|
}
|
|
//
|
that.setData({
|
longitude: resLoc.longitude,
|
latitude: resLoc.latitude,
|
})
|
//发送请求通过经纬度反查地址信息
|
var getAddressUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + resLoc.latitude + "," + resLoc.longitude + "&key=GFDBZ-D3NKX-LNL4Z-TSWGU-RYCE3-4HB3I";
|
wx.request({
|
url: getAddressUrl,
|
success: function (result) {
|
//console.log("getAddressUrl", result);
|
that.setData({
|
userLocAddress: result.data.result.address
|
});
|
}
|
});
|
}
|
});
|
},
|
|
initialTabbar() {
|
var sliderWidth = 96; // 需要设置slider的宽度,用于计算中间位置
|
wx.getSystemInfo({
|
success: res => {
|
this.setData({
|
// sliderLeft: (res.windowWidth / this.data.tabBar.list.length - sliderWidth) / 2 + 2,
|
sliderOffset: res.windowWidth / this.data.tabBar.list.length * this.data.activeIndex
|
});
|
}
|
});
|
},
|
tabClick: function (e) {
|
var tab_id = e.currentTarget.id;
|
//console.log(tab_id)
|
if (tab_id == 1) {
|
if (!this.data.isTtaskFileListLoad) {
|
this.refreshTaskFileList();
|
this.setData({
|
isTtaskFileListLoad: true
|
});
|
}
|
}
|
|
// console.log(tab_id, 41)
|
this.setData({
|
sliderOffset: e.currentTarget.offsetLeft,
|
activeIndex: tab_id
|
});
|
},
|
|
expand_floatMenu: function () {
|
this.setData({
|
floatMenu: {
|
animation: 'animation',
|
bindtaps: "unExpand_floatMenu"
|
}
|
})
|
},
|
unExpand_floatMenu: function () {
|
this.setData({
|
floatMenu: {
|
animation: 'animations',
|
bindtaps: "expand_floatMenu"
|
}
|
})
|
},
|
|
//查看图片(报修)
|
previewRequestImage: function (e) {
|
var bigOriginPath = e.target.dataset.src.OriginPath;
|
var images = this.data.requestImagesList;
|
|
var imagesList = [];
|
for (var i = 0; i < images.length; i++) {
|
imagesList.push(images[i].OriginPath);
|
}
|
wx.previewImage({
|
current: bigOriginPath,
|
urls: imagesList
|
});
|
},
|
//查看图片(维修)
|
previewTaskImage: function (e) {
|
var bigOriginPath = e.target.dataset.src.OriginPath;
|
var imagesList = [];
|
imagesList.push(bigOriginPath);
|
wx.previewImage({
|
current: bigOriginPath,
|
urls: imagesList
|
});
|
},
|
//暂停或重启
|
tapToggleTaskBtn: function (e) {
|
if (this.data.taskFormIsStop) {
|
this.setData({
|
isShowConfirmDlg: true,
|
confirmDlgTitle: "重启备注信息",
|
tapConfirmCb: "tapConfirmRestart" //点击确定,进行的按钮操作类型
|
});
|
} else {
|
this.setData({
|
isShowConfirmDlg: true,
|
confirmDlgTitle: "停工备注信息",
|
tapConfirmCb: "tapConfirmStop" //点击确定,进行的按钮操作类型
|
});
|
}
|
},
|
//刷新
|
tapRefreshBtn: function (e) {
|
//获取当前经纬度
|
this.getCurrentLocation();
|
|
//初始化表单信息
|
this.intialFormInfo();
|
|
},
|
|
//显示确认对话框
|
tapShowConfirmDlg: function () {
|
if (this.data.longitude == 0 || this.data.latitude == 0) {
|
this.getCurrentLocation(); //获取当前经纬度
|
}
|
|
this.setData({
|
confirmDlgTitle: "信息",
|
isShowConfirmDlg: true
|
});
|
},
|
//
|
inputOperateNote: function (e) {
|
this.setData({
|
operateNote: e.detail.value
|
})
|
},
|
/*** 弹出框蒙层截断touchmove事件*/
|
preventTouchMove: function () {},
|
/*** 隐藏模态对话框 */
|
hideConfirmDlg: function () {
|
this.setData({
|
isShowConfirmDlg: false
|
})
|
},
|
/*** 对话框取消按钮点击事件*/
|
onCancel: function () {
|
this.hideConfirmDlg()
|
},
|
//确认 停工
|
tapConfirmStop: function () {
|
var that = this;
|
|
var sysInfo = app.globalData.sysInfo;
|
var userInfo = app.globalData.userInfo;
|
var formEntity = this.data.formEntity;
|
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/Task/Form/Pause@V1.0",
|
method: 'POST',
|
data: {
|
ID: this.data.requestFormId,
|
Note:this.data.operateNote
|
},
|
header: {
|
'content-type': 'application/x-www-form-urlencoded'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
success: function (res) {
|
// console.log(res.data,379);
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.message,
|
});
|
return;
|
}
|
|
var currentBlankID = parseInt(result.ID);
|
formEntity.CurrentBlankID = currentBlankID;
|
|
that.setData({
|
isShowConfirmDlg: false,
|
taskFormIsStop: true, //是否是暂停状态
|
tapToggleTaskIcon: "icon-on",
|
currentBlankID: currentBlankID,
|
formEntity: formEntity,
|
taskFormStatusName: "停工中...",
|
stepFormStatusName: "停工"
|
});
|
|
wx.showToast({
|
title: '已停工',
|
icon: 'success',
|
duration: 2000
|
});
|
|
}
|
});
|
},
|
//确认 重启
|
tapConfirmRestart: function () {
|
var that = this;
|
if (this.data.currentBlankID == 0)
|
return;
|
var formEntity = this.data.formEntity;
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/Task/Form/Restart@V1.0",
|
method: 'POST',
|
data: {
|
ID: that.data.requestFormId,
|
Note:that.data.operateNote
|
},
|
header: {
|
'content-type': 'application/x-www-form-urlencoded'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
success: function (res) {
|
// console.log(res.data,379);
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.message,
|
});
|
return;
|
}
|
|
formEntity.CurrentBlankID = 0;
|
|
that.setData({
|
isShowConfirmDlg: false,
|
taskFormIsStop: false, //是否是暂停状态
|
tapToggleTaskIcon: "icon-off",
|
currentBlankID: 0,
|
formEntity: formEntity,
|
taskFormStatusName: "开工中...",
|
stepFormStatusName: "开工"
|
});
|
|
wx.showToast({
|
title: '已开工',
|
icon: 'success',
|
duration: 2000
|
});
|
}
|
});
|
},
|
|
/**完工 */
|
tapFinishTask: function () {
|
if (this.data.taskFormIsStop) {
|
wx.showToast({
|
title: '当前状态是停工,请先开工,再完工',
|
icon: 'none',
|
duration: 2000
|
});
|
return;
|
}
|
var fromId = this.data.requestFormId;
|
wx.navigateTo({
|
url: '/repair/completeTaskInfo/index?taskformid=' + fromId,
|
})
|
},
|
/**添加 */
|
tapAddTaskFile: function (e) {
|
var taskFormId = this.data.taskFormId;
|
var StatueType = 0 //0表示进行时的状态
|
var taskFileList=this.data.taskFileList
|
var logicID=taskFileList[taskFileList.length-1].ID
|
let formType="taskForm"
|
wx.navigateTo({
|
url: '/repair/addTaskFile/index?taskformid=' + taskFormId + '&StatueType=' + StatueType+ '&formType=' + formType + '&logicID='+logicID,
|
})
|
},
|
//刷新表单
|
refreshTaskFileList: function () { //添加文件后,会回调此页面,所以不要随便改名字
|
var that = this;
|
var taskformid = this.data.taskFormId;
|
// console.log(taskformid,491)
|
wx.showLoading({
|
title: '加载中...'
|
});
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/Task/Form/Std/GetDetailByID@V1.0",
|
method: 'GET',
|
data: {
|
ID: taskformid
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
wx.hideLoading();
|
wx.showModal({
|
title: '',
|
content: '通讯失败',
|
});
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
wx.hideLoading();
|
//console.log(res.data)
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
var allResultFile = result.Data.LogList;
|
// console.log(allResultFile,523)
|
var taskFileList = [];
|
for (var i = 0; i < allResultFile.length; i++) {
|
var taskFile = allResultFile[i];
|
if(taskFile.FileList!=null){
|
for (var j = 0; j < taskFile.FileList.length; j++) {
|
var big_image_name = taskFile.FileList[j].StorageUrl;
|
var th_image_name = taskFile.FileList[j].StorageUrl;
|
// taskFile.Details[j].OriginPath = Constant.BASE_SERVER_URL + "Repair/RepairTaskFile/" + taskformid + "/" + big_image_name;
|
// taskFile.Details[j].ThumbPath = Constant.BASE_SERVER_URL + "Repair/RepairTaskFile/" + taskformid + "/" + th_image_name;
|
taskFile.FileList[j].OriginPath = Constant.BASE_SERVER_URL + big_image_name;
|
taskFile.FileList[j].ThumbPath = Constant.BASE_SERVER_URL + th_image_name;
|
}
|
}
|
taskFileList.push(taskFile);
|
}
|
// console.log(taskFileList,539)
|
that.setData({
|
taskFileList: taskFileList
|
});
|
}
|
});
|
},
|
onReady: function () {},
|
onShow: function () {},
|
onHide: function () {},
|
onUnload: function () {},
|
onPullDownRefresh: function () {},
|
onReachBottom: function () {},
|
onShareAppMessage: function () {
|
return Constant.Share;
|
},
|
})
|