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.

228 lines
5.4 KiB
JavaScript

2 years ago
// pages/jobDetail/ynzzEdit/index.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
from:'',
name:'',
jobDetail:{},
trainingRadio: [
{ value: '0', name: '无培训' },
{ value: '1', name: '有培训' }
],
probationRadio: [
{ value: '0', name: '无试用期' },
{ value: '1', name: '有试用期' }
],
transferFeeRadio: [
{ value: '0', name: '无调单费' },
{ value: '1', name: '有调单费' },
{ value: '2', name: '后期确认' },
],
training: '',
probation: '',
transferFee: '',
},
radioChange (e) {
console.log('radio发生change事件携带value值为', e)
this.data.trainingRadio.forEach(item => {
item.checked = false
if (item.value == e.detail.value) {
item.checked = true
}
});
this.setData({
trainingRadio: this.data.trainingRadio,
training: ''
})
console.log(this.data.trainingRadio);
},
radioChange2 (e) {
console.log('radio发生change事件携带value值为', e.detail.value)
this.data.probationRadio.forEach(item => {
item.checked = false
if (item.value == e.detail.value) {
item.checked = true
}
});
this.setData({
probationRadio: this.data.probationRadio,
probation: ''
})
},
radioChange3 (e) {
console.log('radio发生change事件携带value值为', e.detail.value)
this.data.transferFeeRadio.forEach(item => {
item.checked = false
if (item.value == e.detail.value) {
item.checked = true
}
});
this.setData({
transferFeeRadio: this.data.transferFeeRadio,
transferFee: ''
})
},
formSubmit (e) {
console.log('form发生了submit事件携带数据为', e.detail.value)
var that = this;
wx.showLoading({
title: '提交中...',
})
// e.detail.value['storeJobId'] = wx.getStorageSync('jobDetail').storeJob.id;
let currData = {};
currData["id"] = wx.getStorageSync('jobDetail').storeJob.id;
currData["fieldName"] = that.data.name;
if(e.detail.value.transferFeeRadio == 2){
currData["value"] = "后期确认" + (e.detail.value.transferFee ? '' + e.detail.value.transferFee :'')
}else{
currData["value"] = e.detail.value[that.data.name];
}
let currDataRadio = {};
currDataRadio["id"] = wx.getStorageSync('jobDetail').storeJob.id;
currDataRadio["fieldName"] = `${that.data.name}Radio`;
currDataRadio["value"] = e.detail.value[`${that.data.name}Radio`];
that.save(currData);
that.save(currDataRadio);
setTimeout(function () {
wx.hideLoading({
success: (res) => { },
})
wx.navigateBack({
delta: 1,
})
}, 1000)
},
save(currData){
var that = this;
wx.request({
url: app.globalData.ip + "/store/job/updateJobField",
data: currData,
header: app.globalData.header,
method: "POST",
success: function (res) {
console.log(res)
if (res.data.status == 200) {
console.log(res);
// setTimeout(function () {
// // wx.navigateBack({
// // delta: 1,
// // })
// }, 1000)
} else {
wx.showLoading({
title: '提交失败',
})
wx.hideLoading()
}
},
fail: function (res) {
wx.showLoading({
title: '提交失败',
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
this.setData({
from:options.title,
name:options.name,
})
console.log(this.data.name)
wx.setNavigationBarTitle({
title: options.title,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow () {
const trainingRadio = this.data.trainingRadio
const probationRadio = this.data.probationRadio
const transferFeeRadio = this.data.transferFeeRadio
for (let i = 0, len = trainingRadio.length; i < len; ++i) {
trainingRadio[i].checked = trainingRadio[i].value == wx.getStorageSync('jobDetail').storeJob.trainingRadio
}
for (let i = 0, len = probationRadio.length; i < len; ++i) {
probationRadio[i].checked = probationRadio[i].value == wx.getStorageSync('jobDetail').storeJob.probationRadio
}
for (let i = 0, len = transferFeeRadio.length; i < len; ++i) {
transferFeeRadio[i].checked = transferFeeRadio[i].value == wx.getStorageSync('jobDetail').storeJob.transferFeeRadio
}
this.setData({
trainingRadio,
probationRadio,
transferFeeRadio,
training: wx.getStorageSync('jobDetail').storeJob.training,
probation: wx.getStorageSync('jobDetail').storeJob.probation,
transferFee: wx.getStorageSync('jobDetail').storeJob.transferFee,
jobDetail: wx.getStorageSync('jobDetail')
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage () {
}
})