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.

562 lines
19 KiB
JavaScript

2 years ago
// 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,
resultValue: -1,
storeContactList: [],//面试官
storeContactIndex: 0,
followFailLabelList: [],//安置失败原因
followFailLabelListIndex: 0,
contactDialog:false,
serviceOrderId: '21',//工单ID
followId: '1569',//跟进ID
processed: 0,
userFollow:{},
serviceOrder:{},
orderStatusTimeYMD: '',
orderStatusTimeYMDCurr: '请选择',
orderStatusTimeHM: '',
orderStatusTimeHMCurr: '请选择',
//
orderStatusEntryTimeYMD: '',
orderStatusEntryTimeYMDCurr: '请选择',
orderStatusEntryTimeHM: '',
orderStatusEntryTimeHMCurr: '请选择',
//
workTypeArrTmp: [],//工种类型
loading:false,
userServeRecords: [],
notifyTimeArray: commonUtil.getNotifyTimeArray(),//延迟时间
notifyTimeArrayIndex: 0,
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;
if (app.globalData.isLogin) {
that.getServiceOrder();
that.findAllFollowFailLabels();
} else {
app.userWechatAuth(999);
app.userLoginCallback = res => {
that.getServiceOrder();
that.findAllFollowFailLabels();
}
}
},
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);
console.log(that.data.serviceOrder);
//=================================userFollow=====================================start
that.data.userFollow.sex = commonUtil.getSex(that.data.userFollow.sex);
if (app.isNotEmptyCheck(that.data.userFollow.birthday)) {
that.data.userFollow.age = commonUtil.getAgeFromBirthday(that.data.userFollow.birthday) + '岁';
} else {
that.data.userFollow.age = '';
}
//=================================userFollow=====================================end
//=================================serviceOrder=====================================start
that.data.serviceOrder.jobType = commonUtil.getJobTypeById(that.data.serviceOrder.jobType);
that.data.serviceOrder.workType = 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=====================================start
that.data.jobDetail.jobHire = commonUtil.showStoreJobHireTotalNum2(that.data.jobDetail.state, that.data.jobDetail.numType, that.data.jobDetail.numMale, that.data.jobDetail.numFemale);
//=================================jobDetail=====================================end
if (that.data.serviceOrder.orderStatus == 10) {
that.data.result = [{id: -1, name: '请选择'}, {id: 5, name: '确认可以面试'}, {id: 6, name: '不能面试'}];
} else if (that.data.serviceOrder.orderStatus == 20) {
// that.data.result = [{id: -1, name: '请选择'}, {id: 9, name: '确认已到面'}, {id: 10, name: '未能到面'}];
that.data.result = [{id: -1, name: '请选择'}, {id: 11, name: '面试通过'}, {id: 12, name: '面试未通过'}, {id: 10, name: '未能到面'}];
} else if (that.data.serviceOrder.orderStatus == 40) {
that.data.result = [{id: -1, name: '请选择'}, {id: 7, name: '确认重新约面'}, {id: 8, name: '不能重新约面'}];
}
// else if (that.data.serviceOrder.orderStatus == 30) {
// that.data.result = [{id: -1, name: '请选择'}, {id: 11, name: '面试通过'}, {id: 12, name: '面试未通过'}];
// }
/*if (that.data.serviceOrder.orderStatus == 10) {
that.data.pageTitle = '约面';
} else if (that.data.serviceOrder.orderStatus == 40) {
that.data.pageTitle = '重新约面';
} else if (that.data.serviceOrder.orderStatus == 20) {
that.data.pageTitle = '面试';
}*/
/*else if (that.data.serviceOrder.orderStatus == 30) {
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,
processed: that.data.serviceOrder.state - 1 == 0 ? 0 : 1,
userServeRecords: res.data.data.userServeRecords,
});
console.log(res.data.data.userServeRecords);
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);
}
})
},
findAllFollowFailLabels: function() {
var that = this;
wx.request({
url: app.globalData.ip + '/labels/findAllFollowFailLabels',
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);
that.setData({
followFailLabelList: scList,
});
} else {
//app.showTips(that, res.data.msg);
}
},
fail: function (res) {
console.log(res);
}
})
},
addUserServeRecord: function(e) {
var that = this;
var notifyTimeMinute = that.data.notifyTimeArray[that.data.notifyTimeArrayIndex].value;
//传递参数
var paramData = {
followId: that.data.followId,
serviceOrderId: that.data.serviceOrderId,
desp: e.detail.value.desp,
notifyTimeMinute: notifyTimeMinute,
};
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
})
}
})
},
interviewCheck: function(e) {
var that = this;
if (that.data.loading) {
return
}
that.data.loading = true;
that.setData({
loading: true
})
var interviewType = that.data.result[that.data.resultIndex].id;
if (interviewType == -1) {//只写备注
that.addUserServeRecord(e);
return;
// that.setData({
// loading: false
// })
// wx.showToast({
// title: '请选择约面结果',
// icon: 'none',
// duration: 2000
// })
// return;
}
//传递参数
var paramData = {
followId: that.data.followId,
serviceOrderId: that.data.serviceOrderId,
interviewType: interviewType,
desp: e.detail.value.desp,
};
if (interviewType == 11 || interviewType == 12) {//面试时间
console.log(that.data.orderStatusTimeYMD+"=================");
if (this.data.orderStatusTimeYMDCurr == "请选择" || this.data.orderStatusTimeHMCurr =="请选择") {
that.setData({
loading: false
})
wx.showToast({
title: '请选择面试时间',
icon: 'none',
duration: 2000
})
return;
}
paramData['orderStatusTime'] = that.data.orderStatusTimeYMD + ' ' + that.data.orderStatusTimeHM;
paramData['interviewTimeStr'] = that.data.orderStatusTimeYMD + ' ' + that.data.orderStatusTimeHM;
}
if (interviewType == 5 || interviewType == 7 || interviewType == 11 || interviewType == 12) {//需要面试官
if (that.data.storeContactIndex == 0) {
that.setData({
loading: false
})
wx.showToast({
title: '请选择约面试官',
icon: 'none',
duration: 2000
})
return;
}
paramData['interviewer'] = that.data.storeContactList[that.data.storeContactIndex].id;
paramData['contactName'] = that.data.storeContactList[that.data.storeContactIndex].contactName;
paramData['contactTel'] = that.data.storeContactList[that.data.storeContactIndex].tel;
}
/*if (that.data.resultValue == 11) {//入职时间
if (this.data.orderStatusEntryTimeYMDCurr == "请选择" || this.data.orderStatusEntryTimeHMCurr =="请选择") {
that.setData({
loading: false
})
wx.showToast({
title: '请选择入职时间',
icon: 'none',
duration: 2000
})
return;
}
paramData['entryTimeStr'] = that.data.orderStatusEntryTimeYMD + ' ' + that.data.orderStatusEntryTimeHM;
}*/
if (this.data.orderStatusEntryTimeYMDCurr != "请选择" && this.data.orderStatusEntryTimeHMCurr !="请选择") {
paramData['entryTimeStr'] = that.data.orderStatusEntryTimeYMD + ' ' + that.data.orderStatusEntryTimeHM;
}
if (interviewType == 12) {//面试未通过
if (that.data.followFailLabelListIndex == 0) {
that.setData({
loading: false
})
wx.showToast({
title: '请选择未通过原因',
icon: 'none',
duration: 2000
})
return;
}
paramData['failReasonIds'] = that.data.followFailLabelList[that.data.followFailLabelListIndex].id;
paramData['failReasonDesp'] = that.data.followFailLabelList[that.data.followFailLabelListIndex].name;
}
wx.request({
url: app.globalData.ip + '/user/serviceOrder/console/interviewCheck',
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 {
}
},
fail: function (res) {
console.log(res);
that.setData({
loading: false
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
bindResultChange: function(e) {
console.log('picker bindResultChange 发生选择改变,携带值为', e.detail.value);
var that = this;
var resultValue = that.data.result[e.detail.value].id;
if(e.detail.value != 0 && app.isNotEmptyCheck(that.data.serviceOrder.interviewer)) {
if(app.isNotEmptyCheck(that.data.serviceOrder.interviewer)) {//初始化面试官下拉框
that.data.storeContactList.forEach((item, index) => {
if (item.id == that.data.serviceOrder.interviewer) {
that.data.storeContactIndex = index;
return false;
}
});
}
} else {
that.data.storeContactIndex = 0;
}
if (resultValue == 11 || resultValue == 12) {//设置默认面试时间
that.data.orderStatusTimeYMD = dateUtil.getDateYMD();
that.data.orderStatusTimeHM = dateUtil.getHour() + ':00';
}
if (resultValue == 11) {//设置默认入职时间
that.data.orderStatusEntryTimeYMD = dateUtil.getDateYMD();
that.data.orderStatusEntryTimeHM = '12:00';
}
this.setData({
resultIndex: e.detail.value,
resultValue: resultValue,
storeContactIndex: that.data.storeContactIndex,
orderStatusTimeYMD: that.data.orderStatusTimeYMD,
orderStatusTimeHM: that.data.orderStatusTimeHM,
orderStatusEntryTimeYMD: that.data.orderStatusEntryTimeYMD,
orderStatusEntryTimeHM: that.data.orderStatusEntryTimeHM,
})
},
bindStoreContactChange: function(e) {
console.log('picker bindStoreContactChange 发生选择改变,携带值为', e.detail.value);
this.setData({
storeContactIndex: e.detail.value
})
},
bindNotifyTimeChange: function(e) {
console.log('picker bindNotifyTimeChange 发生选择改变,携带值为', e.detail.value);
this.setData({
notifyTimeArrayIndex: e.detail.value
})
},
bindChangeFollowFailLabel: function(e) {
console.log('picker bindChangeFollowFailLabel 发生选择改变,携带值为', e.detail.value);
this.setData({
followFailLabelListIndex: e.detail.value
})
},
bindDateChangeOrderStatusTimeYMD: function(e) {
console.log('picker bindDateChangeOrderStatusTimeYMD 发生选择改变,携带值为', e.detail.value);
this.setData({
orderStatusTimeYMD: e.detail.value,
orderStatusTimeYMDCurr: e.detail.value,
})
},
bindDateChangeOrderStatusTimeHM: function(e) {
console.log('picker bindDateChangeOrderStatusTimeHM 发生选择改变,携带值为', e.detail.value);
this.setData({
orderStatusTimeHM: e.detail.value,
orderStatusTimeHMCurr: e.detail.value,
})
},
bindDateChangeOrderStatusEntryTimeYMD: function(e) {
console.log('picker bindDateChangeOrderStatusEntryTimeYMD 发生选择改变,携带值为', e.detail.value);
this.setData({
orderStatusEntryTimeYMD: e.detail.value,
orderStatusEntryTimeYMDCurr: e.detail.value,
})
},
bindDateChangeOrderStatusEntryTimeHM: function(e) {
console.log('picker bindDateChangeOrderStatusEntryTimeHM 发生选择改变,携带值为', e.detail.value);
this.setData({
orderStatusEntryTimeHM: e.detail.value,
orderStatusEntryTimeHMCurr: e.detail.value,
})
},
makePhone: function(e) {
console.log(e);
let telNum = e.currentTarget.dataset['tel'];
wx.makePhoneCall({
phoneNumber: telNum //仅为示例,并非真实的电话号码
})
},
copy: function() {
var that = this;
// var jobInfo = '';
// if (app.isNotEmptyCheck(that.data.serviceOrder.workType)) {
// jobInfo += '' + that.getWorkTypeById(this.userFollow.workType);
// }
// if (app.isNotEmptyCheck(this.userFollow.salaryType)) {
// jobInfo += '' + getSalaryTypeById(this.userFollow.salaryType);
// }
wx.setClipboardData({
// data: '张三 女 29岁',
data: '打勾网 - 推荐面试信息 \n\n'
+ that.data.userFollow.userName + ' ' + that.data.userFollow.sex + ' ' + that.data.userFollow.age + (app.isNotEmptyCheck(that.data.userFollow.telephone) ? ' - ' + that.data.userFollow.telephone :'') +'\n\n'
+ '应聘「' + that.data.userFollow.storeName + ' - ' + that.data.userFollow.jobLabelName + '」'
+ (app.isNotEmptyCheck(that.data.serviceOrder.workType) ? '' + that.data.serviceOrder.workType : '')
+ (app.isNotEmptyCheck(that.data.userFollow.salaryTypeSettlementCycle) ? '' + that.data.userFollow.salaryTypeSettlementCycle : '') +'\n\n'
+ '预计「' + that.data.serviceOrder.orderStatusTimeStr +'」面试'
+ (app.isNotEmptyCheck(that.data.serviceOrder.desp) ? '\n\n备注' + that.data.serviceOrder.desp : '' ),
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(){
wx.navigateTo({
url: '/pages/editOrder/index',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
})