| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- import {
- resumeExp
- } from '../../services/index.js'
- import {
- imgServerUrl
- } from '../../config/config.js'
- import {
- showToast
- } from '../../utils/tips.js'
- import {
- formatNumber,
- formateYM,
- formatetime,
- } from '../../utils/util.js'
- const app = getApp();
- let end_time = [];
- Page({
- data: {
- imgServerUrl: imgServerUrl,
- comName: '',
- jobName: '',
- startDate: '请选择',
- endDate: '请选择',
- startDateEnd: '',
- endTime: formatetime(new Date(), '-', false),
- hpUserExpId: '', //求职者工作经验表
- hpUserResumeId: '', //用户简历表id
- years: [],
- months: [],
- pick_view: true,
- touch_end: true,
- disabled: false,
- show_delete: false
- },
- onLoad: function (options) {
- this.pushYear();
- // this.pushMonths();
- let {
- hpUserResumeId,
- index
- } = options
- if (typeof index != "undefined") {
- let expList = wx.getStorageSync('expList')[index]
- this.setData({
- comName: expList.workCompany,
- jobName: expList.workPosition,
- hpUserResumeId: expList.resumeId,
- hpUserExpId: expList.id,
- startDate: expList.workStartDate ? expList.workStartDate : "请选择",
- endDate: expList.workEndDate ? expList.workEndDate : "请选择",
- show_delete: true
- }, _ => {
- this.check()
- })
- } else {
- this.setData({
- hpUserResumeId
- }, _ => {
- this.check()
- })
- }
- },
- pushYear() {
- const year = new Date().getFullYear();
- const mouth = new Date().getMonth();
- const _len = year - 2015;
- const years = this.data.years;
- for (let i = 0; i <= _len; i++) {
- years.push(2015 + i + '年')
- }
- years.push('至今');
- end_time[0] = years.length - 2;
- end_time[1] = mouth;
- this.setData({
- years,
- }, _ => {
- this.pushMonths(end_time);
- })
- },
- pushMonths(end_time) {
- // const end_time = this.data.end_time;
- const mouth = new Date().getMonth() + 1;
- const months = [];
- const _len = this.data.years.length;
- if (this.data.years[end_time[0]] === '至今') {
- this.setData({
- months: []
- }, _ => {
- this.setData({
- end_time
- })
- })
- return
- }
- if (end_time[0] === _len - 2) {
- for (let i = 0; i < mouth; i++) {
- months.push(i + 1)
- }
- this.setData({
- months: months.map(formatNumber)
- }, _ => {
- this.setData({
- end_time
- })
- })
- return
- }
- this.setData({
- months: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
- }, _ => {
- this.setData({
- end_time
- })
- })
- },
- showEndDate() {
- this.setData({
- pick_view: false
- })
- },
- endDateCancel() {
- this.setData({
- pick_view: true
- })
- },
- endDateSure() {
- if (this.data.touch_end) {
- const years = this.data.years;
- const months = this.data.months;
- if (end_time[0] === years.length - 1) {
- this.setData({
- endDate: years[years.length - 1],
- pick_view: true,
- }, _ => {
- this.check()
- })
- } else {
- this.setData({
- endDate: `${years[end_time[0]]}${Number(months[end_time[1]])}月`,
- pick_view: true,
- }, _ => {
- this.check()
- })
- }
- }
- },
- catchtap() {
- },
- touchEnd() {
- this.setData({
- touch_end: true
- })
- },
- touchStart() {
- this.setData({
- touch_end: false
- })
- },
- //入职时间
- startDateChange(e) {
- const time = e.detail.value.split('-');
- this.setData({
- startDate: `${time[0]}年${time[1]}月`
- }, _ => {
- this.check()
- })
- },
- //离职时间
- endDateChange(e) {
- end_time = e.detail.value;
- if (end_time[1] > this.data.months.length - 1) {
- end_time[1] = this.data.months.length - 1
- }
- if (end_time[1] < 0) {
- end_time[1] = 0
- }
- // this.setData({
- // end_time: end_time,
- // })
- this.pushMonths(end_time);
- // this.setData({
- // endDate: formateYM(e.detail.value)
- // })
- },
- //公司名称
- changeComName(e) {
- this.setData({
- comName: e.detail.value.excludeSpecial().excludeSpace()
- }, _ => {
- this.check()
- })
- },
- //工作职位
- changeJobName(e) {
- this.setData({
- jobName: e.detail.value.excludeSpecial().excludeSpace()
- }, _ => {
- this.check()
- })
- },
- delete() {
- },
- //验证
- check(status = false) {
- let {
- comName,
- jobName,
- startDate,
- endDate
- } = this.data;
- this.setData({
- disabled: false
- })
- if (comName == "") {
- status && showToast('请填写公司名称')
- return false
- }
- if (jobName == "") {
- status && showToast("请填写职位")
- return false
- }
- if (startDate == '请选择') {
- status && showToast("请选择入职时间")
- return false
- }
- if (endDate == '请选择') {
- status && showToast("请选择离职时间")
- return false
- }
- this.setData({
- disabled: true
- })
- return true
- },
- submit() {
- let flag = this.check(true)
- if (!flag) {
- return
- }
- let {
- comName,
- jobName,
- hpUserResumeId,
- hpUserExpId,
- startDate,
- endDate
- } = this.data
- let paramsObj = {
- resumeId: hpUserResumeId,
- workCompany: comName,
- workPosition: jobName,
- workStartDate: startDate,
- workEndDate: endDate,
- workExperienceId: hpUserExpId,
- user_id: app.globalData.userId,
- user_token: app.globalData.userToken,
- member_id: app.globalData.memberId
- }
- Object.assign(paramsObj);
- resumeExp(paramsObj).then(data => {
- showToast('保存成功', 'success')
- wx.navigateBack()
- })
- },
- })
|