388 lines
10 KiB
JavaScript
388 lines
10 KiB
JavaScript
import {
|
|
getUserEnterpriseInfo,
|
|
updateUserInfo,
|
|
updateUserPhoto,
|
|
getDictionaries
|
|
} from "../../../api/index";
|
|
import {
|
|
FILEPATHPRE
|
|
} from "../../../utils/util"
|
|
import Dialog from '@vant/weapp/dialog/dialog';
|
|
Page({
|
|
data: {
|
|
FILEPATHPRE: FILEPATHPRE,
|
|
degreeOfEducationList: [],
|
|
dutiesList: [],
|
|
nationList: [],
|
|
politicalList: [],
|
|
degreeName: '',
|
|
politicaName: '',
|
|
nationName: '',
|
|
dutiesName: '',
|
|
fileList: [],
|
|
form: {},
|
|
rules: {
|
|
"NAME": "请输入姓名",
|
|
// "PHONE": "请输入手机号",
|
|
"NATION": "请输入民族",
|
|
"POLITICAL_OUTLOOK": "请输入政治面貌",
|
|
"DEGREE_OF_EDUCATION": "请选择文化程度",
|
|
"HEALTH_CONDITION": "请选择健康状况",
|
|
"GRADUATION_INSTITUTION": "请输入毕业院校",
|
|
// "DUTIES": "请输入专业",
|
|
"TITLE": "请输入职务/职称",
|
|
"DOMICILE": "请输入职户籍所在地",
|
|
"WORKING_DATE": "请输入参加工作日期",
|
|
"WORK_HOURS": "请输入之前从事时间",
|
|
"WORK_EXPERIENCE": "请输入工作经历",
|
|
"CERTIFICATES": "请输入证书等情况",
|
|
"PUNISH": "请输入处罚等情况",
|
|
"ENTRY_DATE": "请输入进入本单位时间",
|
|
},
|
|
CORPINFO_ID: '',
|
|
currentDate: Date.now(),
|
|
entryDate: Date.now(),
|
|
show: false,
|
|
showEntry: false,
|
|
showDegree: false,
|
|
showPolitica: false,
|
|
showNation: false,
|
|
showDuties: false,
|
|
formatter(type, value) {
|
|
if (type === 'year') {
|
|
return `${value}年`;
|
|
}
|
|
if (type === 'month') {
|
|
return `${value}月`;
|
|
}
|
|
if (type === 'day') {
|
|
return `${value}日`;
|
|
}
|
|
return value;
|
|
},
|
|
minDate: new Date('1900-01-01').getTime(),
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
// this.getDuties()
|
|
this.getDegree()
|
|
this.getNation()
|
|
this.getPolitical()
|
|
this.setData({
|
|
CORPINFO_ID: options.CORPINFO_ID
|
|
})
|
|
this.getData()
|
|
},
|
|
/**
|
|
* 专业
|
|
*/
|
|
// async getDuties() {
|
|
// let resData = await getDictionaries({
|
|
// DICTIONARIES_ID: '95530fecbcb3421ca600b58c206b99d6'
|
|
// })
|
|
// this.setData({
|
|
// dutiesList: resData.list
|
|
// })
|
|
// },
|
|
/**
|
|
* 文化程度
|
|
*/
|
|
async getDegree() {
|
|
let resData = await getDictionaries({
|
|
DICTIONARIES_ID: 'd7d80f08d73a4accbccf4fd3d8d1d867'
|
|
})
|
|
this.setData({
|
|
degreeOfEducationList: resData.list
|
|
})
|
|
},
|
|
/**
|
|
* 民族
|
|
*/
|
|
async getNation() {
|
|
let resData = await getDictionaries({
|
|
DICTIONARIES_ID: '0a0e406f27f74ee698fe9979d25f62dd'
|
|
})
|
|
this.setData({
|
|
nationList: resData.list
|
|
})
|
|
},
|
|
/**
|
|
* 政治面貌
|
|
*/
|
|
async getPolitical() {
|
|
let resData = await getDictionaries({
|
|
DICTIONARIES_ID: '6351efdd12dc4730952e5d195718e252'
|
|
})
|
|
this.setData({
|
|
politicalList: resData.list
|
|
})
|
|
},
|
|
/**
|
|
* 初始数据
|
|
*/
|
|
async getData() {
|
|
let resData = await getUserEnterpriseInfo({
|
|
CORPINFO_ID: this.data.CORPINFO_ID
|
|
})
|
|
this.setData({
|
|
form: resData.userInfo
|
|
})
|
|
if(resData.userInfo.PORTRAIT){
|
|
let url = FILEPATHPRE + resData.userInfo.PORTRAIT
|
|
const { fileList = [] } = this.data;
|
|
fileList.push({ url: url});
|
|
this.setData({ fileList });
|
|
}
|
|
if (resData.userInfo.DEGREE_OF_EDUCATION_NAME) {
|
|
this.setData({
|
|
degreeName: resData.userInfo.DEGREE_OF_EDUCATION_NAME
|
|
})
|
|
}
|
|
if (resData.userInfo.NATION_EDUCATION_NAME) {
|
|
this.setData({
|
|
nationName: resData.userInfo.NATION_EDUCATION_NAME
|
|
})
|
|
}
|
|
if (resData.userInfo.POLITICAL_OUTLOOK_EDUCATION_NAME) {
|
|
this.setData({
|
|
politicaName: resData.userInfo.POLITICAL_OUTLOOK_EDUCATION_NAME
|
|
})
|
|
}
|
|
// if (resData.userInfo.DUTIES_EDUCATION_NAME) {
|
|
// this.setData({
|
|
// dutiesName: resData.userInfo.DUTIES_EDUCATION_NAME
|
|
// })
|
|
// }
|
|
},
|
|
/**
|
|
* 时间选择器
|
|
*/
|
|
showPopFn() {
|
|
this.setData({ show: true });
|
|
},
|
|
showEntryFn() {
|
|
this.setData({ showEntry: true });
|
|
},
|
|
showDegreeFn() {
|
|
this.setData({ showDegree: true });
|
|
},
|
|
showPoliticalFn() {
|
|
this.setData({ showPolitica: true });
|
|
},
|
|
showNationFn() {
|
|
this.setData({ showNation: true });
|
|
},
|
|
showDutiesFn() {
|
|
this.setData({ showDuties: true });
|
|
},
|
|
/**
|
|
* 时间选择器 - 关闭
|
|
*/
|
|
onClose() {
|
|
this.setData({ show: false });
|
|
},
|
|
onCloseEntry() {
|
|
this.setData({ showEntry: false });
|
|
},
|
|
onCloseDegree() {
|
|
this.setData({ showDegree: false });
|
|
},
|
|
onClosePolitica() {
|
|
this.setData({ showPolitica: false });
|
|
},
|
|
onCloseNation() {
|
|
this.setData({ showNation: false });
|
|
},
|
|
onCloseDuties() {
|
|
this.setData({ showDuties: false });
|
|
},
|
|
/**
|
|
* 时间选择器 - 确定按钮
|
|
*/
|
|
confirmFn() {
|
|
var time = new Date(this.data.currentDate);
|
|
var timeStr = this.timeFormat(time)
|
|
var form = this.data.form
|
|
form.WORKING_DATE = timeStr
|
|
this.setData({ show: false,form: form });
|
|
},
|
|
conEntryFn() {
|
|
var time = new Date(this.data.entryDate);
|
|
var timeStr = this.timeFormat(time)
|
|
var form = this.data.form
|
|
form.ENTRY_DATE = timeStr
|
|
this.setData({ showEntry: false,form: form });
|
|
},
|
|
onConfirmDegree(event) {
|
|
var form = this.data.form
|
|
form.DEGREE_OF_EDUCATION = event.detail.value.DICTIONARIES_ID
|
|
this.setData({
|
|
degreeName: event.detail.value.NAME,
|
|
form: form,
|
|
showDegree: false
|
|
});
|
|
},
|
|
onConfirmPolitica(event) {
|
|
var form = this.data.form
|
|
form.POLITICAL_OUTLOOK = event.detail.value.DICTIONARIES_ID
|
|
this.setData({
|
|
politicaName: event.detail.value.NAME,
|
|
form: form,
|
|
showPolitica: false
|
|
});
|
|
},
|
|
onConfirmNation(event) {
|
|
var form = this.data.form
|
|
form.NATION = event.detail.value.DICTIONARIES_ID
|
|
this.setData({
|
|
nationName: event.detail.value.NAME,
|
|
form: form,
|
|
showNation: false
|
|
});
|
|
},
|
|
onConfirmDuties(event) {
|
|
var form = this.data.form
|
|
form.DUTIES = event.detail.value.DICTIONARIES_ID
|
|
this.setData({
|
|
dutiesName: event.detail.value.NAME,
|
|
form: form,
|
|
showDuties: false
|
|
});
|
|
},
|
|
/**
|
|
* 获取时间
|
|
*/
|
|
onInput(event) {
|
|
this.setData({
|
|
currentDate: event.detail,
|
|
});
|
|
},
|
|
onEntryInput(event) {
|
|
this.setData({
|
|
entryDate: event.detail,
|
|
});
|
|
},
|
|
/**
|
|
* 日期格式化
|
|
*/
|
|
timeFormat(time) {
|
|
let year = time.getFullYear();
|
|
let month = time.getMonth() + 1;
|
|
let day = time.getDate();
|
|
return year + '-' + month + '-' + day
|
|
},
|
|
/**
|
|
* 底部确定按钮
|
|
*/
|
|
async submitUpdate(){
|
|
if(this.data.fileList.length === 0){
|
|
wx.showToast({
|
|
title: '请上传头像',
|
|
icon: "none"
|
|
})
|
|
return;
|
|
}
|
|
for (const rulesKey in this.data.rules) {
|
|
if (!this.data.form[rulesKey]) {
|
|
wx.showToast({
|
|
title: this.data.rules[rulesKey],
|
|
icon: "none"
|
|
})
|
|
return;
|
|
}
|
|
}
|
|
// let PHONE = this.data.form.PHONE
|
|
// if (!(/^1[34578]\d{9}$/.test(PHONE))) {
|
|
// wx.showToast({
|
|
// title: '手机号有误',
|
|
// icon: 'none',
|
|
// })
|
|
// return;
|
|
// }
|
|
const resData = await updateUserInfo({
|
|
NAME: this.data.form.NAME,
|
|
SEX: this.data.form.SEX,
|
|
USERNAME: this.data.form.USERNAME,
|
|
NATION: this.data.form.NATION,
|
|
POLITICAL_OUTLOOK: this.data.form.POLITICAL_OUTLOOK,
|
|
DEGREE_OF_EDUCATION: this.data.form.DEGREE_OF_EDUCATION,
|
|
HEALTH_CONDITION: this.data.form.HEALTH_CONDITION,
|
|
GRADUATION_INSTITUTION: this.data.form.GRADUATION_INSTITUTION,
|
|
TITLE: this.data.form.TITLE,
|
|
DOMICILE: this.data.form.DOMICILE,
|
|
WORKING_DATE: this.data.form.WORKING_DATE,
|
|
STUDENT_DEPARTMENT: this.data.form.STUDENT_DEPARTMENT,
|
|
TYPE_OF_WORK: this.data.form.TYPE_OF_WORK,
|
|
WORK_EXPERIENCE: this.data.form.WORK_EXPERIENCE,
|
|
CERTIFICATES: this.data.form.CERTIFICATES,
|
|
PUNISH: this.data.form.PUNISH,
|
|
WORK_HOURS: this.data.form.WORK_HOURS,
|
|
PHONE: this.data.form.PHONE,
|
|
DUTIES: this.data.form.DUTIES,
|
|
PERSONNEL_TYPE: this.data.form.PERSONNEL_TYPE,
|
|
PORTRAIT: this.data.form.PORTRAIT,
|
|
ENTRY_DATE: this.data.form.ENTRY_DATE,
|
|
CORPINFO_ID: this.data.CORPINFO_ID,
|
|
})
|
|
wx.showToast({
|
|
title: '修改成功',
|
|
mask: true
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1500)
|
|
},
|
|
bindInput(event) {
|
|
this.setData({
|
|
form: {
|
|
...this.data.form,
|
|
[event.currentTarget.dataset.key]: event.detail,
|
|
}
|
|
})
|
|
},
|
|
deleteFile(){
|
|
Dialog.confirm({
|
|
title: '提示',
|
|
message: '确定删除头像吗?',
|
|
})
|
|
.then(() => {
|
|
// on confirm
|
|
this.setData({
|
|
fileList: [],
|
|
form:{
|
|
...this.data.form,
|
|
PORTRAIT:''
|
|
}
|
|
})
|
|
})
|
|
.catch(() => {
|
|
// on cancel
|
|
});
|
|
},
|
|
afterRead(event) {
|
|
const { file } = event.detail;
|
|
updateUserPhoto({
|
|
filePath: file.url,
|
|
}).then((res) => {
|
|
// 上传完成需要更新 fileList
|
|
const { fileList = [] } = this.data;
|
|
fileList.push({ ...file, url: res.data });
|
|
this.setData({ fileList });
|
|
this.setData({
|
|
form: {
|
|
...this.data.form,
|
|
PORTRAIT: res.pd.PORTRAIT,
|
|
}
|
|
})
|
|
}).catch((e) => {
|
|
wx.showToast({
|
|
title: '上传头像失败,请稍后再试',
|
|
mask: false,
|
|
icon: error
|
|
})
|
|
})
|
|
},
|
|
})
|