index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import {
  2. resumeExp
  3. } from '../../services/index.js'
  4. import {
  5. imgServerUrl
  6. } from '../../config/config.js'
  7. import {
  8. showToast
  9. } from '../../utils/tips.js'
  10. import {
  11. formatNumber,
  12. formateYM,
  13. formatetime,
  14. } from '../../utils/util.js'
  15. const app = getApp();
  16. let end_time = [];
  17. Page({
  18. data: {
  19. imgServerUrl: imgServerUrl,
  20. comName: '',
  21. jobName: '',
  22. startDate: '请选择',
  23. endDate: '请选择',
  24. startDateEnd: '',
  25. endTime: formatetime(new Date(), '-', false),
  26. hpUserExpId: '', //求职者工作经验表
  27. hpUserResumeId: '', //用户简历表id
  28. years: [],
  29. months: [],
  30. pick_view: true,
  31. touch_end: true,
  32. disabled: false,
  33. show_delete: false
  34. },
  35. onLoad: function (options) {
  36. this.pushYear();
  37. // this.pushMonths();
  38. let {
  39. hpUserResumeId,
  40. index
  41. } = options
  42. if (typeof index != "undefined") {
  43. let expList = wx.getStorageSync('expList')[index]
  44. this.setData({
  45. comName: expList.workCompany,
  46. jobName: expList.workPosition,
  47. hpUserResumeId: expList.resumeId,
  48. hpUserExpId: expList.id,
  49. startDate: expList.workStartDate ? expList.workStartDate : "请选择",
  50. endDate: expList.workEndDate ? expList.workEndDate : "请选择",
  51. show_delete: true
  52. }, _ => {
  53. this.check()
  54. })
  55. } else {
  56. this.setData({
  57. hpUserResumeId
  58. }, _ => {
  59. this.check()
  60. })
  61. }
  62. },
  63. pushYear() {
  64. const year = new Date().getFullYear();
  65. const mouth = new Date().getMonth();
  66. const _len = year - 2015;
  67. const years = this.data.years;
  68. for (let i = 0; i <= _len; i++) {
  69. years.push(2015 + i + '年')
  70. }
  71. years.push('至今');
  72. end_time[0] = years.length - 2;
  73. end_time[1] = mouth;
  74. this.setData({
  75. years,
  76. }, _ => {
  77. this.pushMonths(end_time);
  78. })
  79. },
  80. pushMonths(end_time) {
  81. // const end_time = this.data.end_time;
  82. const mouth = new Date().getMonth() + 1;
  83. const months = [];
  84. const _len = this.data.years.length;
  85. if (this.data.years[end_time[0]] === '至今') {
  86. this.setData({
  87. months: []
  88. }, _ => {
  89. this.setData({
  90. end_time
  91. })
  92. })
  93. return
  94. }
  95. if (end_time[0] === _len - 2) {
  96. for (let i = 0; i < mouth; i++) {
  97. months.push(i + 1)
  98. }
  99. this.setData({
  100. months: months.map(formatNumber)
  101. }, _ => {
  102. this.setData({
  103. end_time
  104. })
  105. })
  106. return
  107. }
  108. this.setData({
  109. months: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
  110. }, _ => {
  111. this.setData({
  112. end_time
  113. })
  114. })
  115. },
  116. showEndDate() {
  117. this.setData({
  118. pick_view: false
  119. })
  120. },
  121. endDateCancel() {
  122. this.setData({
  123. pick_view: true
  124. })
  125. },
  126. endDateSure() {
  127. if (this.data.touch_end) {
  128. const years = this.data.years;
  129. const months = this.data.months;
  130. if (end_time[0] === years.length - 1) {
  131. this.setData({
  132. endDate: years[years.length - 1],
  133. pick_view: true,
  134. }, _ => {
  135. this.check()
  136. })
  137. } else {
  138. this.setData({
  139. endDate: `${years[end_time[0]]}${Number(months[end_time[1]])}月`,
  140. pick_view: true,
  141. }, _ => {
  142. this.check()
  143. })
  144. }
  145. }
  146. },
  147. catchtap() {
  148. },
  149. touchEnd() {
  150. this.setData({
  151. touch_end: true
  152. })
  153. },
  154. touchStart() {
  155. this.setData({
  156. touch_end: false
  157. })
  158. },
  159. //入职时间
  160. startDateChange(e) {
  161. const time = e.detail.value.split('-');
  162. this.setData({
  163. startDate: `${time[0]}年${time[1]}月`
  164. }, _ => {
  165. this.check()
  166. })
  167. },
  168. //离职时间
  169. endDateChange(e) {
  170. end_time = e.detail.value;
  171. if (end_time[1] > this.data.months.length - 1) {
  172. end_time[1] = this.data.months.length - 1
  173. }
  174. if (end_time[1] < 0) {
  175. end_time[1] = 0
  176. }
  177. // this.setData({
  178. // end_time: end_time,
  179. // })
  180. this.pushMonths(end_time);
  181. // this.setData({
  182. // endDate: formateYM(e.detail.value)
  183. // })
  184. },
  185. //公司名称
  186. changeComName(e) {
  187. this.setData({
  188. comName: e.detail.value.excludeSpecial().excludeSpace()
  189. }, _ => {
  190. this.check()
  191. })
  192. },
  193. //工作职位
  194. changeJobName(e) {
  195. this.setData({
  196. jobName: e.detail.value.excludeSpecial().excludeSpace()
  197. }, _ => {
  198. this.check()
  199. })
  200. },
  201. delete() {
  202. },
  203. //验证
  204. check(status = false) {
  205. let {
  206. comName,
  207. jobName,
  208. startDate,
  209. endDate
  210. } = this.data;
  211. this.setData({
  212. disabled: false
  213. })
  214. if (comName == "") {
  215. status && showToast('请填写公司名称')
  216. return false
  217. }
  218. if (jobName == "") {
  219. status && showToast("请填写职位")
  220. return false
  221. }
  222. if (startDate == '请选择') {
  223. status && showToast("请选择入职时间")
  224. return false
  225. }
  226. if (endDate == '请选择') {
  227. status && showToast("请选择离职时间")
  228. return false
  229. }
  230. this.setData({
  231. disabled: true
  232. })
  233. return true
  234. },
  235. submit() {
  236. let flag = this.check(true)
  237. if (!flag) {
  238. return
  239. }
  240. let {
  241. comName,
  242. jobName,
  243. hpUserResumeId,
  244. hpUserExpId,
  245. startDate,
  246. endDate
  247. } = this.data
  248. let paramsObj = {
  249. resumeId: hpUserResumeId,
  250. workCompany: comName,
  251. workPosition: jobName,
  252. workStartDate: startDate,
  253. workEndDate: endDate,
  254. workExperienceId: hpUserExpId,
  255. user_id: app.globalData.userId,
  256. user_token: app.globalData.userToken,
  257. member_id: app.globalData.memberId
  258. }
  259. Object.assign(paramsObj);
  260. resumeExp(paramsObj).then(data => {
  261. showToast('保存成功', 'success')
  262. wx.navigateBack()
  263. })
  264. },
  265. })