var Constant = require('../../utils/constant.js');
|
var app = getApp();
|
import Request from "../../utils/api"
|
Page({
|
|
data: {
|
//报修图片
|
requestImagesList: [],
|
resultImagesFiles: [],
|
taskFileList: [],
|
currentCorpID: 1,
|
currentUserID: 1, //当前用户ID
|
stepStatusStyle: [], //步骤样式
|
requestFormId: 0,
|
taskFormId: 0,
|
formEntity: {},
|
|
taskResult:"",//维修结果
|
taskFormStatus: 1,
|
logDetailInfo: {},
|
taskLogList: [], //时间轴数据
|
isTtaskFileListLoad: false,
|
|
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-wancheng",
|
"selectedIconPath": "icon-wancheng 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": "操作日志"
|
}]
|
},
|
activeIndex: 0,
|
sliderOffset: 0,
|
sliderLeft: 0
|
},
|
|
//
|
onLoad: function (options) {
|
var that = this;
|
|
var userInfo = app.globalData.userInfo;
|
if (userInfo) {
|
this.setData({
|
currentCorpID: userInfo.CorpID,
|
currentUserID: userInfo.EmployeeID
|
});
|
} else {
|
wx.navigateTo({
|
url: '/login/login/index',
|
});
|
}
|
|
if (options.requestformid == '' || options.requestformid == undefined)
|
return;
|
var requestFormId = options.requestformid;
|
// console.log(requestFormId);
|
|
this.setData({
|
requestFormId: options.requestformid
|
});
|
|
|
//
|
this.initialTabbar();
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/RepairTaskForm/Mobile/GetMyHasFinishedDetailByID@V1.0",
|
method: 'GET',
|
data: {
|
CorpID: Constant.CorpID,
|
ID: requestFormId,
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
console.log(err,94)
|
wx.showModal({
|
title: '',
|
content: '通讯失败',
|
});
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
//
|
console.log(res,102)
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: "获取详细失败",
|
});
|
return;
|
}
|
var formEntity = result.Data;
|
console.log(formEntity)
|
|
var requestImagesList = [];
|
let FileList = formEntity.RequestForm.FileList
|
if (FileList != null && FileList.length > 0) {
|
for (var i = 0; i < FileList.length; i++) {
|
var big_image_name = FileList[i].StorageUrl;
|
var th_image_name = FileList[i].StorageUrl;
|
|
var m = {};
|
m.OriginPath = Constant.BASE_SERVER_URL + big_image_name;
|
m.ThumbPath = Constant.BASE_SERVER_URL + th_image_name;
|
requestImagesList.push(m);
|
}
|
}
|
var taskformid = formEntity.ID;
|
var resultImagesList = [];
|
if (FileList != null && FileList.length > 0) {
|
for (var i = 0; i < FileList.length; i++) {
|
var big_image_name = FileList[i].StorageUrl;
|
var th_image_name = FileList[i].StorageUrl;
|
|
var m = {};
|
m.OriginPath = Constant.BASE_SERVER_URL + big_image_name;
|
m.ThumbPath = Constant.BASE_SERVER_URL + th_image_name;
|
resultImagesList.push(m);
|
}
|
}
|
|
var taskFileList = [];
|
|
for (var k = 0; k < formEntity.LogList.length; k++) {
|
var taskFile = formEntity.LogList[k];
|
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.FileList[j].OriginPath = Constant.BASE_SERVER_URL + big_image_name;
|
taskFile.FileList[j].ThumbPath = Constant.BASE_SERVER_URL + th_image_name;
|
taskFile.FileList[j].OperateTime = taskFile.OperateTime
|
taskFile.FileList[j].OperateUserName = taskFile.OperateUserName
|
|
taskFileList.push(taskFile.FileList[j]);
|
}
|
}
|
console.log(taskFileList,156)
|
//计算流程步骤
|
that.calcStepStatusStyle(formEntity);
|
|
//
|
var taskLogList = formEntity.LogList;
|
// console.log(taskLogList,"ywg149")
|
taskLogList.forEach(ele => {
|
if(ele.OperateContent == "受理"){
|
formEntity.AcceptTime = ele.OperateTime
|
}
|
});
|
|
let taskResult = taskLogList[taskLogList.length - 1]
|
var taskResultImagesList = [];
|
if (taskResult.FileList != null && taskResult.FileList.length > 0) {
|
for (var i = 0; i < taskResult.FileList.length; i++) {
|
var big_image_name = taskResult.FileList[i].StorageUrl;
|
var th_image_name = taskResult.FileList[i].StorageUrl;
|
|
var m = {};
|
m.OriginPath = Constant.BASE_SERVER_URL + big_image_name;
|
m.ThumbPath = Constant.BASE_SERVER_URL + th_image_name;
|
taskResultImagesList.push(m);
|
}
|
}
|
taskResult.FileList = taskResultImagesList
|
//
|
that.setData({
|
formEntity: formEntity,
|
taskFormId: taskformid,
|
taskLogList: taskLogList,
|
taskResult:taskResult,
|
taskFileList:taskFileList,
|
resultImagesFiles: resultImagesList,
|
requestImagesList: requestImagesList
|
});
|
}
|
});
|
|
|
|
},
|
//计算步骤样式
|
calcStepStatusStyle: function (formEntity) {
|
var that = this;
|
var taskFormStatus = formEntity.FormStatus;
|
|
var stepStatusStyle = [];
|
stepStatusStyle.push("form-step-item-finish");
|
stepStatusStyle.push("form-step-item-unfinish");
|
stepStatusStyle.push("form-step-item-unfinish");
|
stepStatusStyle.push("form-step-item-unfinish");
|
stepStatusStyle.push("form-step-item-unfinish");
|
stepStatusStyle.push("form-step-item-unfinish");
|
stepStatusStyle.push("form-step-item-unfinish");
|
if (taskFormStatus == 10) {
|
stepStatusStyle[1] = "form-step-item-active";
|
}
|
if (taskFormStatus > 10) {
|
stepStatusStyle[1] = "form-step-item-finish";
|
}
|
|
if (taskFormStatus == 20) {
|
stepStatusStyle[2] = "form-step-item-active";
|
}
|
if (taskFormStatus > 20) {
|
stepStatusStyle[2] = "form-step-item-finish";
|
}
|
|
if (taskFormStatus == 40) {
|
stepStatusStyle[3] = "form-step-item-active";
|
}
|
if (taskFormStatus > 40) {
|
stepStatusStyle[3] = "form-step-item-finish";
|
}
|
|
if (taskFormStatus == 100) {
|
stepStatusStyle[4] = "form-step-item-active";
|
}
|
if (taskFormStatus > 100) {
|
stepStatusStyle[4] = "form-step-item-finish";
|
}
|
|
if (taskFormStatus >= 200) {
|
stepStatusStyle[5] = "form-step-item-finish";
|
}
|
|
that.setData({
|
stepStatusStyle: stepStatusStyle,
|
taskFormStatus: taskFormStatus
|
});
|
},
|
//
|
initialTabbar: function () {
|
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;
|
if (tab_id == 1) {
|
var taskFormStatus = this.data.taskFormStatus;
|
if (taskFormStatus < 100) { //未完工
|
return;
|
}
|
} else if (tab_id == 2) {
|
var taskFormStatus = this.data.taskFormStatus;
|
if (taskFormStatus < 40) { //未开工
|
return;
|
}
|
if (!this.data.isTtaskFileListLoad) {
|
// this.refreshTaskFileList();
|
this.setData({
|
isTtaskFileListLoad: true
|
});
|
}
|
}
|
|
// console.log(tab_id, 41)
|
this.setData({
|
sliderOffset: e.currentTarget.offsetLeft,
|
activeIndex: tab_id
|
});
|
},
|
/**添加 */
|
tapAddTaskFile: function () {
|
var taskFormId = this.data.taskFormId;
|
var StatueType = 3 //3表示已完成的状态
|
wx.navigateTo({
|
url: '/repair/addTaskFile/index?taskformid=' + taskFormId + '&StatueType=' + StatueType,
|
})
|
},
|
//点击日志
|
tapTaskLog: function (e) {
|
// console.log(e.currentTarget.dataset.logid, e.currentTarget.dataset );
|
// var logid = e.currentTarget.dataset.logid;
|
var logid = e.currentTarget.dataset.logid;
|
if (logid == null || logid == 0)
|
return;
|
//console.log(logid)
|
wx.navigateTo({
|
url: '/repair/logDetail/index?logid=' + logid // + '&UserName=' + dataset.UserName + '&StepName=' + dataset.StepName,
|
})
|
},
|
|
//刷新表单
|
refreshTaskFileList: function () { //添加文件后,会回调此页面,所以不要随便改名字
|
var that = this;
|
var taskformid = this.data.taskFormId;
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/Mobile/TaskFile/GetByTaskID",
|
method: 'GET',
|
data: {
|
SoftType: Constant.SoftType,
|
PortType: Constant.PortType,
|
TaskID: taskformid
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
// console.log("TaskID:" +taskformid, res.data)
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
var allResultFile = result.Data;
|
|
if (allResultFile == null || allResultFile.length == 0) {
|
return; //表示没有上传图片
|
}
|
|
|
var taskFileList = [];
|
|
for (var i = 0; i < allResultFile.length; i++) {
|
var taskFile = allResultFile[i];
|
for (var j = 0; j < taskFile.Details.length; j++) {
|
var big_image_name = taskFile.Details[j].DataSetFile;
|
var th_image_name = taskFile.Details[j].ThumbnailFile;
|
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;
|
}
|
|
taskFileList.push(taskFile);
|
}
|
|
|
//console.log(taskFileList)
|
that.setData({
|
taskFileList: taskFileList
|
});
|
}
|
});
|
},
|
|
//查看图片(报修)
|
previewRequesImage: function (e) {
|
var that = this;
|
var imagesList = [];
|
var current = e.target.dataset.src.OriginPath;
|
var images = that.data.requestImagesList;
|
for (var i = 0; i < images.length; i++) {
|
imagesList.push(images[i].OriginPath)
|
}
|
// console.log(current, imagesList, "bigPicture:大图", "smallPicture:小图")
|
wx.previewImage({
|
current: current,
|
urls: imagesList
|
})
|
},
|
//查看图片(维修完成)
|
previewResultImage: function (e) {
|
var that = this;
|
var imagesList = [];
|
var current = e.target.dataset.src.OriginPath
|
var images = that.data.resultImagesFiles;
|
for (var i = 0; i < images.length; i++) {
|
imagesList.push(images[i].OriginPath)
|
}
|
// console.log(current, imagesList, "bigPicture:大图", "smallPicture:小图")
|
wx.previewImage({
|
current: current,
|
urls: imagesList
|
})
|
},
|
//查看图片(维修)
|
previewTaskImage: function (e) {
|
var bigOriginPath = e.target.dataset.src.OriginPath;
|
var imagesList = [];
|
imagesList.push(bigOriginPath);
|
wx.previewImage({
|
current: bigOriginPath,
|
urls: imagesList
|
});
|
},
|
onReady: function () {},
|
onShow: function () {},
|
onHide: function () {},
|
onUnload: function () {},
|
onPullDownRefresh: function () {},
|
onReachBottom: function () {},
|
onShareAppMessage: function () {
|
return Constant.Share;
|
},
|
})
|