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.

494 lines
17 KiB
JavaScript

2 years ago
// pages/editOrder/index.js
const app = getApp();
const commonUtil = require('../../utils/commonUtil.js');
const dateUtil = require('../../utils/dateUtil.js');
Page({
/**
* 页面的初始数据
*/
data: {
result: ["确认可以面试", "确认不可以面试", "面试未通过"],
resultIndex: 0,
topTips: false,
hide: false,
pageTitle:'',
people: ["石涛", "石涛1", "石涛2"],
peopleIndex: 0,
contactDialog:false,
serviceOrderId: '21',//工单ID
followId: '1569',//跟进ID
userFollow:{},
serviceOrder:{},
orderStatusTimeYMD: dateUtil.getTodayYYYYMMDD(),
orderStatusTimeHM: '00:00',
workTypeArrTmp: [],//工种类型
workTypeArrTmpIndex: 0,
salaryList: [],//薪资标准列表
salaryListIndex: 0,//薪资标准列表
storeJobList: [],//职位列表
storeJobListIndex: 0,//职位列表
loading:false,
jobTypeName:'',
storeJobId: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var that = this;
that.data.serviceOrderId = options.serviceOrderId;
that.data.followId = options.followId;
that.getServiceOrder();
},
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.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).replace('-', '/').replace('-', '/') + ' ' + dateUtil.getDataName(that.data.userFollow.interviewTime);
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).replace('-', '/').replace('-', '/') + ' ' + dateUtil.getDataName(that.data.serviceOrder.orderStatusTime);
that.data.serviceOrder.orderStatusTimeOldStr = dateUtil.formatDateYMDHM(that.data.serviceOrder.orderStatusTimeOld).replace('-', '/').replace('-', '/') + ' ' + dateUtil.getDataName(that.data.serviceOrder.orderStatusTimeOld);
if (that.data.serviceOrder.orderStatus == 50 && 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 == 50) {
that.data.result = [{id: -1, name: '请选择'}, {id: 7, name: '确认重约入职'}, {id: 8, name: '不能重约入职'}];
} else if (that.data.serviceOrder.orderStatus == 60) {
that.data.result = [{id: -1, name: '请选择'}, {id: 5, name: '确认在职中'}, {id: 6, name: '未能入职'}];
} else if (that.data.serviceOrder.orderStatus == 70) {
that.data.result = [{id: -1, name: '请选择'}, {id: 9, name: '确认交付'}, {id: 10, name: '尚未交付'}];
}
if (that.data.serviceOrder.orderStatus == 50) {
that.data.pageTitle = '重约入职';
} else if (that.data.serviceOrder.orderStatus == 60) {
that.data.pageTitle = '入职';
} else if (that.data.serviceOrder.orderStatus == 70) {
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,
jobTypeName: that.data.serviceOrder.jobType,
storeJobId: that.data.serviceOrder.storeJobId,
});
that.getJobSalaryByJobId();
that.getStoreJobListByStoreId();
} else {
//app.showTips(that, res.data.msg);
}
},
fail: function (res) {
console.log(res);
}
})
},
getJobSalaryByJobId: function() {
var that = this;
var storeJobId = that.data.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) {
that.data.salaryList = [];
var saList = [{id: -1, salaryTypeSettlementCycle: '请选择'}];
that.data.salaryList = saList.concat(res.data.data);
if(that.data.storeJobId - that.data.serviceOrder.storeJobId != 0) {//重选职位
that.setData({
salaryList: that.data.salaryList,
salaryListIndex: that.data.salaryList.length > 1 ? 1 : 0,
});
return;
}
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);
}
})
},
getStoreJobListByStoreId: function() {
var that = this;
var storeId = that.data.serviceOrder.storeId;
wx.request({
url: app.globalData.ip + '/store/job/getJobByStoreId',
data: {
storeId: storeId
},
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res.data);
if (res.data.status == 200) {
var saList = [{id: -1, jobName: '请选择'}];
that.data.storeJobList = saList.concat(res.data.data);
var salaryId = -1;
if (app.isEmptyCheck(that.data.storeJobList) && that.data.storeJobList.length == 1) {
if (app.isNotEmptyCheck(that.data.userFollow) && app.isNotEmptyCheck(that.data.userFollow.storeJobId)) {
salaryId = -2;
that.data.storeJobList.push({ id: -2, jobName: that.data.userFollow.jobLabelName});
}
} else {
var hasRecord = false;
for (var i = 0; i != that.data.storeJobList.length; ++i) {
if (that.data.storeJobList[i].id - that.data.userFollow.storeJobId == 0) {
hasRecord = true;
salaryId = that.data.storeJobList[i].id;
break;
}
}
if (!hasRecord && app.isNotEmptyCheck(that.data.userFollow.storeJobId)) {
salaryId = -2;
that.data.storeJobList.push({ id: -2, jobName: that.data.userFollow.jobLabelName});
}
}
that.data.storeJobList.forEach((item, index) => {
if (item.id == salaryId) {
that.data.storeJobListIndex = index;
}
});
that.setData({
storeJobList: that.data.storeJobList,
storeJobListIndex: that.data.storeJobListIndex,
});
console.log(that.data.storeJobList);
} else {
//app.showTips(that, res.data.msg);
}
},
fail: function (res) {
console.log(res);
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
bindStoreJobChange: function (e) {
var that = this;
that.data.workTypeArrTmp = [];
var workTypeStrs = that.data.storeJobList[e.detail.value].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;
}
});
}
console.log('picker country 发生选择改变,携带值为', e.detail.value);
this.setData({
storeJobListIndex: e.detail.value,
jobTypeName: commonUtil.getJobTypeById(that.data.storeJobList[e.detail.value].jobType),
workTypeArrTmpIndex: that.data.workTypeArrTmpIndex,
workTypeArrTmp: that.data.workTypeArrTmp,
storeJobId: that.data.storeJobList[e.detail.value].id,
salaryList: [],
salaryListIndex: 0,
})
that.getJobSalaryByJobId();
},
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
})
},
open: function () {
this.setData({
topTips: true,
loading:true
});
setTimeout(() => {
this.setData({
topTips: false,
hide: false,
loading: false
});
}, 2000);
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
updateStoreInfo: function(e) {
console.log(e);
var that = this;
that.setData({
loading: true
})
//传递参数
var paramData = {
followId: that.data.followId,
serviceOrderId: that.data.serviceOrderId,
storeId: that.data.serviceOrder.storeId,
storeName: that.data.serviceOrder.storeName,
};
if (that.data.storeJobListIndex == 0) {
that.setData({
loading: false
})
wx.showToast({
title: '请选择职位',
icon: 'none',
duration: 2000
})
return;
}
if (that.data.workTypeArrTmpIndex == 0) {
that.setData({
loading: false
})
wx.showToast({
title: '请选择需求类型',
icon: 'none',
duration: 2000
})
return;
}
/*if (that.data.salaryListIndex == 0) {
that.setData({
loading: false
})
wx.showToast({
title: '请选择薪资标准',
icon: 'none',
duration: 2000
})
return;
}*/
if (that.data.salaryListIndex != 0) {
paramData['salary'] = that.data.salaryList[that.data.salaryListIndex].salary;
paramData['salaryType'] = that.data.salaryList[that.data.salaryListIndex].salaryType;
paramData['settlementCycle'] = that.data.salaryList[that.data.salaryListIndex].settlementCycle;
}
paramData['storeJobId'] = that.data.storeJobList[that.data.storeJobListIndex].id;
paramData['jobLabelId'] = that.data.storeJobList[that.data.storeJobListIndex].jobLabelId;
paramData['jobName'] = that.data.storeJobList[that.data.storeJobListIndex].jobName;
paramData['jobType'] = that.data.storeJobList[that.data.storeJobListIndex].jobType;
paramData['workType'] = that.data.workTypeArrTmp[that.data.workTypeArrTmpIndex].id;
wx.request({
url: app.globalData.ip + '/user/serviceOrder/console/updateFollowInfo',
data: paramData,
header: app.globalData.header,
method: "POST",
success: function (res) {
console.log(res.data);
if (res.data.status == 200) {
var pages = getCurrentPages();
console.log(pages);
wx.navigateBack({
delta: 1
})
} else {
//app.showTips(that, res.data.msg);
}
},
fail: function (res) {
console.log(res);
}
})
},
})