You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
559 lines
19 KiB
JavaScript
559 lines
19 KiB
JavaScript
// pages/orderDetail/index.js
|
|
const app = getApp();
|
|
const commonUtil = require('../../utils/commonUtil.js');
|
|
const dateUtil = require('../../utils/dateUtil.js');
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageTitle:'',
|
|
result: [],
|
|
resultIndex: 0,
|
|
people: ["石涛", "石涛1", "石涛2"],
|
|
peopleIndex: 0,
|
|
contactDialog:false,
|
|
serviceOrderId: '21',//工单ID
|
|
followId: '1569',//跟进ID
|
|
processed: 0,
|
|
userFollow:{},
|
|
serviceOrder:{},
|
|
orderStatusTimeYMD: dateUtil.getTodayYYYYMMDD(),
|
|
orderStatusTimeHM: '00:00',
|
|
workTypeArrTmp: [],//工种类型
|
|
workTypeArrTmpIndex: 0,
|
|
dismissionReasonArrTmp: [],//离职原因
|
|
dismissionReasonArrTmpIndex: 0,
|
|
salaryList: [],//薪资标准列表
|
|
salaryListIndex: 0,//薪资标准列表
|
|
loading:false,
|
|
storeContactList: [],//面试官
|
|
userServeRecords: [],
|
|
comeFrom: -1,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
var that = this;
|
|
if (app.isNotEmptyCheck(options.comeFrom)) {
|
|
that.data.comeFrom = options.comeFrom;
|
|
}
|
|
that.data.serviceOrderId = options.serviceOrderId;
|
|
that.data.followId = options.followId;
|
|
that.setData({
|
|
serviceOrderId: options.serviceOrderId,
|
|
followId: options.followId,
|
|
});
|
|
|
|
},
|
|
getServiceOrder: function() {
|
|
var that = this;
|
|
wx.request({
|
|
url: app.globalData.ip + '/user/serviceOrder/console/getFollowDetails',
|
|
data: {
|
|
serviceOrderId: that.data.serviceOrderId,
|
|
followId: that.data.followId,
|
|
},
|
|
header: app.globalData.header,
|
|
method: "POST",
|
|
success: function (res) {
|
|
|
|
console.log(res.data);
|
|
if (res.data.status == 200) {
|
|
|
|
that.data.userFollow = res.data.data.userFollow;
|
|
that.data.serviceOrder = res.data.data.serviceOrder;
|
|
that.data.pageTitle = res.data.data.serviceOrderStatusName;
|
|
that.data.jobDetail = res.data.data.jobDetail;
|
|
console.log(that.data.userFollow);
|
|
|
|
// that.data.userFollow.followUpTimeStr = new Date(that.data.userFollow.followUpTime.replace(/-/g, "/")).getTime()
|
|
|
|
//=================================userFollow=====================================end
|
|
that.data.userFollow.sex = commonUtil.getSex(that.data.userFollow.sex);
|
|
that.data.userFollow.interviewTimeStr = dateUtil.formatDateYMDHM(that.data.userFollow.interviewTime) + ' ' + dateUtil.getDataName(that.data.userFollow.interviewTime);
|
|
that.data.userFollow.entryTimeStr = dateUtil.formatDateYMDHM(that.data.userFollow.entryTime) + ' ' + dateUtil.getDataName(that.data.userFollow.entryTime);
|
|
if (app.isNotEmptyCheck(that.data.userFollow.birthday)) {
|
|
that.data.userFollow.age = commonUtil.getAgeFromBirthday(that.data.userFollow.birthday) + '岁';
|
|
}
|
|
//=================================userFollow=====================================end
|
|
//=================================serviceOrder=====================================end
|
|
that.data.serviceOrder.jobType = commonUtil.getJobTypeById(that.data.serviceOrder.jobType);
|
|
that.data.serviceOrder.workTypeStr = commonUtil.getWorkTypeById(that.data.serviceOrder.workType);
|
|
that.data.serviceOrder.orderStatusTimeStr = dateUtil.formatDateYMDHM(that.data.serviceOrder.orderStatusTime) + ' ' + dateUtil.getDataName(that.data.serviceOrder.orderStatusTime);
|
|
that.data.serviceOrder.orderStatusTimeOldStr = dateUtil.formatDateYMDHM(that.data.serviceOrder.orderStatusTimeOld) + ' ' + dateUtil.getDataName(that.data.serviceOrder.orderStatusTimeOld);
|
|
|
|
if (app.isNotEmptyCheck(that.data.serviceOrder.orderStatusTime)) {
|
|
var orderStatusTimeStr = dateUtil.formatDateYMDHM(that.data.serviceOrder.orderStatusTime);
|
|
that.data.orderStatusTimeYMD = orderStatusTimeStr.split(' ')[0];
|
|
that.data.orderStatusTimeHM = orderStatusTimeStr.split(' ')[1];
|
|
}
|
|
//=================================serviceOrder=====================================end
|
|
//=================================jobDetail=====================================end
|
|
that.data.jobDetail.jobHire = commonUtil.showStoreJobHireTotalNum2(that.data.jobDetail.state, that.data.jobDetail.numType, that.data.jobDetail.numMale, that.data.jobDetail.numFemale);
|
|
|
|
var workTypeStrs = that.data.jobDetail.workTypeMulti;
|
|
if (!app.isEmptyCheck(workTypeStrs)) {
|
|
var artTmp = workTypeStrs.split(',');
|
|
var workTypeArr = commonUtil.workTypeArray();
|
|
|
|
for (var j = 0; j != artTmp.length; ++j) {
|
|
for (var i = 0; i != workTypeArr.length; ++i) {
|
|
if (artTmp[j] - workTypeArr[i].id == 0) {
|
|
that.data.workTypeArrTmp.push(workTypeArr[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
var wta = [{id: -1, name: '请选择',value:"-1",text:"请选择", checked: false}];
|
|
that.data.workTypeArrTmp = wta.concat(that.data.workTypeArrTmp);
|
|
that.data.workTypeArrTmp.forEach((item, index) => {
|
|
if (item.id - that.data.serviceOrder.workType == 0) {
|
|
that.data.workTypeArrTmpIndex = index;
|
|
}
|
|
});
|
|
|
|
}
|
|
//=================================jobDetail=====================================end
|
|
|
|
if (that.data.serviceOrder.orderStatus == 75) {
|
|
that.data.result = [{id: -1, name: '请选择'}, {id: 5, name: '确认预约离职'}, {id: 6, name: '不能预约离职'}];
|
|
} else if (that.data.serviceOrder.orderStatus == 80) {
|
|
that.data.result = [{id: -1, name: '请选择'}, {id: 5, name: '确认已离职'}, {id: 6, name: '尚未离职'}];
|
|
}
|
|
|
|
/*if (that.data.serviceOrder.orderStatus == 75) {
|
|
that.data.pageTitle = '预约离职';
|
|
} else if (that.data.serviceOrder.orderStatus == 80) {
|
|
that.data.pageTitle = '离职';
|
|
}*/
|
|
|
|
wx.setNavigationBarTitle({
|
|
title: that.data.pageTitle
|
|
})
|
|
|
|
that.setData({
|
|
pageTitle: that.data.pageTitle,
|
|
userFollow: that.data.userFollow,
|
|
serviceOrder: that.data.serviceOrder,
|
|
jobDetail: that.data.jobDetail,
|
|
result: that.data.result,
|
|
orderStatusTimeYMD: that.data.orderStatusTimeYMD,
|
|
orderStatusTimeHM: that.data.orderStatusTimeHM,
|
|
workTypeArrTmp: that.data.workTypeArrTmp,
|
|
workTypeArrTmpIndex: that.data.workTypeArrTmpIndex,
|
|
processed: that.data.serviceOrder.state - 1 == 0 ? 0 : 1,
|
|
userServeRecords: res.data.data.userServeRecords,
|
|
});
|
|
console.log(res.data.data.userServeRecords);
|
|
that.getJobSalaryByJobId();
|
|
that.findAllDimissionReasonLabels();
|
|
that.getStoreContactByStoreId(that.data.serviceOrder.storeId);
|
|
} else {
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
}
|
|
})
|
|
},
|
|
getStoreContactByStoreId: function (storeId) {
|
|
var that = this;
|
|
wx.request({
|
|
url: app.globalData.ip + '/store/contact/getStoreContactByStoreId',
|
|
data: {
|
|
storeId: storeId,
|
|
},
|
|
header: app.globalData.header,
|
|
method: "POST",
|
|
success: function (res) {
|
|
console.log(res.data);
|
|
if (res.data.status == 200) {
|
|
var scList = [{ id: -1, contactName: '请选择' }];
|
|
scList = scList.concat(res.data.data);
|
|
|
|
that.setData({
|
|
storeContactList: scList,
|
|
});
|
|
} else {
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
}
|
|
})
|
|
},
|
|
addUserServeRecord: function(e) {
|
|
var that = this;
|
|
|
|
//传递参数
|
|
var paramData = {
|
|
followId: that.data.followId,
|
|
serviceOrderId: that.data.serviceOrderId,
|
|
desp: e.detail.value.desp,
|
|
};
|
|
if (app.isEmptyCheck(e.detail.value.desp)) {
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
wx.showToast({
|
|
title: '请输入备注',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
return;
|
|
}
|
|
|
|
wx.request({
|
|
url: app.globalData.ip + '/user/serviceOrder/console/addUserServeRecord',
|
|
data: paramData,
|
|
header: app.globalData.header,
|
|
method: "POST",
|
|
success: function (res) {
|
|
console.log(res.data);
|
|
if (res.data.status == 200) {
|
|
wx.redirectTo({
|
|
url: '/pages/success/index?pageTitle=' + that.data.pageTitle + '&comeFrom=' + that.data.comeFrom
|
|
})
|
|
|
|
} else {
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
}
|
|
})
|
|
},
|
|
entryCheck: function(e) {
|
|
console.log(e);
|
|
var that = this;
|
|
|
|
if (that.data.loading) {
|
|
return
|
|
}
|
|
that.data.loading = true;
|
|
that.setData({
|
|
loading: true
|
|
})
|
|
var entryType = that.data.result[that.data.resultIndex].id;
|
|
if (entryType == -1) {//只写备注
|
|
that.addUserServeRecord(e);
|
|
return;
|
|
// that.setData({
|
|
// loading: false
|
|
// })
|
|
// if(that.data.serviceOrder.orderStatus == 75) {//预约离职结果
|
|
// wx.showToast({
|
|
// title: '请选择预约离职结果',
|
|
// icon: 'none',
|
|
// duration: 2000
|
|
// })
|
|
// } else if(that.data.serviceOrder.orderStatus == 80) {//离职结果
|
|
// wx.showToast({
|
|
// title: '请选择离职结果',
|
|
// icon: 'none',
|
|
// duration: 2000
|
|
// })
|
|
// }
|
|
|
|
|
|
// return;
|
|
}
|
|
//传递参数
|
|
var paramData = {
|
|
followId: that.data.followId,
|
|
serviceOrderId: that.data.serviceOrderId,
|
|
followEntryType: entryType,
|
|
followLeaveType: entryType,
|
|
desp: e.detail.value.desp,
|
|
};
|
|
|
|
if (entryType == 5 && that.data.serviceOrder.orderStatus == 80) {//确认已离职
|
|
if (app.isEmptyCheck(that.data.orderStatusTimeYMD) || app.isEmptyCheck(that.data.orderStatusTimeHM)) {
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
wx.showToast({
|
|
title: '请选择离职时间',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
return;
|
|
}
|
|
|
|
if (that.data.dismissionReasonArrTmpIndex == 0) {
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
wx.showToast({
|
|
title: '请选择离职原因',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
return;
|
|
}
|
|
|
|
paramData['leaveTimeStr'] = that.data.orderStatusTimeYMD + ' ' + that.data.orderStatusTimeHM;
|
|
|
|
paramData['dismissionReasonId'] = that.data.dismissionReasonArrTmp[that.data.dismissionReasonArrTmpIndex].id;
|
|
paramData['dismissionReasonName'] = that.data.dismissionReasonArrTmp[that.data.dismissionReasonArrTmpIndex].name;
|
|
|
|
}
|
|
var reqUrl = app.globalData.ip + '/user/serviceOrder/console/followLeaveCheck';
|
|
if(that.data.serviceOrder.orderStatus == 80) {//离职
|
|
reqUrl = app.globalData.ip + '/user/serviceOrder/console/leaveCheck';
|
|
}
|
|
wx.request({
|
|
url: reqUrl,
|
|
data: paramData,
|
|
header: app.globalData.header,
|
|
method: "POST",
|
|
success: function (res) {
|
|
console.log(res.data);
|
|
if (res.data.status == 200) {
|
|
wx.redirectTo({
|
|
url: '/pages/success/index?pageTitle=' + that.data.pageTitle
|
|
})
|
|
|
|
} else {
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
that.setData({
|
|
loading: false
|
|
})
|
|
}
|
|
})
|
|
},
|
|
getJobSalaryByJobId: function() {
|
|
var that = this;
|
|
|
|
var storeJobId = that.data.userFollow.storeJobId;
|
|
wx.request({
|
|
url: app.globalData.ip + '/store/job/salary/getJobSalaryNameByJobId',
|
|
data: {
|
|
jobId: storeJobId
|
|
},
|
|
header: app.globalData.header,
|
|
method: "POST",
|
|
success: function (res) {
|
|
console.log(res.data);
|
|
if (res.data.status == 200) {
|
|
|
|
var saList = [{id: -1, salaryTypeSettlementCycle: '请选择'}];
|
|
that.data.salaryList = saList.concat(res.data.data);
|
|
|
|
var salaryId = -1;
|
|
if (app.isEmptyCheck(that.data.salaryList) && that.data.salaryList.length == 1) {
|
|
if (app.isNotEmptyCheck(that.data.userFollow) && app.isNotEmptyCheck(that.data.userFollow.salaryType)) {
|
|
salaryId = -2;
|
|
that.data.salaryList.push({ id: -2, salaryTypeSettlementCycle: that.data.userFollow.salaryTypeSettlementCycle, salaryType: that.data.userFollow.salaryType, salary: that.data.userFollow.salary, settlementCycle: that.data.userFollow.settlementCycle});
|
|
}
|
|
} else {
|
|
|
|
var hasRecord = false;
|
|
|
|
for (var i = 0; i != that.data.salaryList.length; ++i) {
|
|
if (that.data.salaryList[i].salaryType - that.data.userFollow.salaryType == 0 && that.data.salaryList[i].salary - that.data.userFollow.salary == 0 && that.data.salaryList[i].settlementCycle - that.data.userFollow.settlementCycle == 0) {
|
|
hasRecord = true;
|
|
salaryId = that.data.salaryList[i].id;
|
|
break;
|
|
}
|
|
}
|
|
if (!hasRecord && app.isNotEmptyCheck(that.data.userFollow.salaryType)) {
|
|
salaryId = -2;
|
|
that.data.salaryList.push({ id: -2, salaryTypeSettlementCycle: that.data.userFollow.salaryTypeSettlementCycle, salaryType: that.data.userFollow.salaryType, salary: that.data.userFollow.salary, settlementCycle: that.data.userFollow.settlementCycle});
|
|
}
|
|
|
|
}
|
|
|
|
that.data.salaryList.forEach((item, index) => {
|
|
if (item.id == salaryId) {
|
|
that.data.salaryListIndex = index;
|
|
}
|
|
});
|
|
|
|
that.setData({
|
|
salaryList: that.data.salaryList,
|
|
salaryListIndex: that.data.salaryListIndex,
|
|
});
|
|
|
|
console.log(that.data.salaryList);
|
|
|
|
} else {
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
}
|
|
})
|
|
},
|
|
findAllDimissionReasonLabels: function() {
|
|
var that = this;
|
|
wx.request({
|
|
url: app.globalData.ip + '/dimissionApply/getDimissionReson',
|
|
data: {},
|
|
header: app.globalData.header,
|
|
method: "POST",
|
|
success: function (res) {
|
|
console.log(res.data);
|
|
if (res.data.status == 200) {
|
|
var scList = [{id: -1, name: '请选择'}];
|
|
scList = scList.concat(res.data.data.labels);
|
|
scList.forEach((item, index) => {
|
|
if (item.id == that.data.serviceOrder.canNotArrangeLabelId) {
|
|
that.data.dismissionReasonArrTmpIndex = index;
|
|
}
|
|
});
|
|
that.setData({
|
|
dismissionReasonArrTmp: scList,
|
|
dismissionReasonArrTmpIndex: that.data.dismissionReasonArrTmpIndex,
|
|
});
|
|
} else {
|
|
//app.showTips(that, res.data.msg);
|
|
}
|
|
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
}
|
|
})
|
|
},
|
|
bindDateChangeOrderStatusTimeYMD: function(e) {
|
|
console.log('picker bindDateChangeOrderStatusTimeYMD 发生选择改变,携带值为', e.detail.value);
|
|
this.setData({
|
|
orderStatusTimeYMD: e.detail.value
|
|
})
|
|
},
|
|
bindDateChangeOrderStatusTimeHM: function(e) {
|
|
console.log('picker bindDateChangeOrderStatusTimeHM 发生选择改变,携带值为', e.detail.value);
|
|
this.setData({
|
|
orderStatusTimeHM: e.detail.value
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
var that = this;
|
|
if (app.globalData.isLogin) {
|
|
that.getServiceOrder();
|
|
} else {
|
|
app.userWechatAuth(999);
|
|
app.userLoginCallback = res => {
|
|
that.getServiceOrder();
|
|
}
|
|
}
|
|
},
|
|
bindResultChange: function(e) {
|
|
console.log('picker country 发生选择改变,携带值为', e.detail.value);
|
|
|
|
var that = this;
|
|
|
|
if(e.detail.value == 1) {
|
|
|
|
var resultValue = that.data.result[e.detail.value].id;
|
|
|
|
if (resultValue == 5) {
|
|
that.data.orderStatusTimeYMD = dateUtil.getDateYMD();
|
|
that.data.orderStatusTimeHM = dateUtil.getHour() + ':00';
|
|
}
|
|
|
|
}
|
|
|
|
this.setData({
|
|
resultIndex: e.detail.value,
|
|
orderStatusTimeYMD: that.data.orderStatusTimeYMD,
|
|
orderStatusTimeHM: that.data.orderStatusTimeHM,
|
|
})
|
|
},
|
|
bindPeopleChange: function(e) {
|
|
console.log('picker country 发生选择改变,携带值为', e.detail.value);
|
|
this.setData({
|
|
peopleIndex: e.detail.value
|
|
})
|
|
},
|
|
bindChangeWorkType: function(e) {
|
|
console.log('picker bindChangeWorkType 发生选择改变,携带值为', e.detail.value);
|
|
this.setData({
|
|
workTypeArrTmpIndex: e.detail.value
|
|
})
|
|
},
|
|
bindChangeSalaryType: function(e) {
|
|
console.log('picker bindChangeSalaryType 发生选择改变,携带值为', e.detail.value);
|
|
this.setData({
|
|
salaryListIndex: e.detail.value
|
|
})
|
|
},
|
|
makePhone: function(e) {
|
|
let telNum = e.currentTarget.dataset['tel'];
|
|
wx.makePhoneCall({
|
|
phoneNumber: telNum //仅为示例,并非真实的电话号码
|
|
})
|
|
},
|
|
copy: function() {
|
|
var that = this;
|
|
wx.setClipboardData({
|
|
// data: '张三 女 29岁',
|
|
data: that.data.userFollow.userName + ' ' + that.data.userFollow.sex + ' ' + that.data.userFollow.age,
|
|
success(res) {
|
|
wx.getClipboardData({
|
|
success(res) {
|
|
console.log(res.data) // data
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
contact: function (e) {
|
|
this.setData({
|
|
contactDialog: true
|
|
});
|
|
},
|
|
close: function () {
|
|
this.setData({
|
|
contactDialog: false
|
|
})
|
|
},
|
|
edit:function(){
|
|
var that = this;
|
|
wx.navigateTo({
|
|
url: '/pages/editOrder/index?serviceOrderId=' + that.data.serviceOrderId + "&followId=" + that.data.followId,
|
|
success: function(res) {},
|
|
fail: function(res) {},
|
|
complete: function(res) {},
|
|
})
|
|
},
|
|
}) |