perfect.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view class="content vflex jbetween">
  3. <view >
  4. <view class="box">
  5. <view class="cell">
  6. <view class="label">公司名称</view>
  7. <u-input v-model="experience.content.company_name" border="none" placeholder="请输入"></u-input>
  8. </view>
  9. <view class="cell">
  10. <view class="label">职位名称</view>
  11. <u-input v-model="experience.content.position_name" border="none" placeholder="请输入"></u-input>
  12. </view>
  13. <view class="cell">
  14. <view class="label">在职时间</view>
  15. <view class="hflex acenter jbetween">
  16. <view @click="open('time1')">
  17. <u-input v-model="experience.content.on_job_start" disabled disabledColor="#fff" border="none" placeholder="入职时间"></u-input>
  18. </view>
  19. <u-datetime-picker :minDate="minDate" title="入职时间" :show="show_time1" v-model="newDate" ref="datetimePicker" @confirm="confirmTime1" @cancel="cancel" :formatter="formatter" mode="year-month"></u-datetime-picker>
  20. <view style="margin: 0 20rpx;">-</view>
  21. <view @click="open('time2')">
  22. <u-input v-model="experience.content.on_job_end" disabled disabledColor="#fff" border="none" placeholder="离职时间"></u-input>
  23. </view>
  24. <u-datetime-picker :minDate="minDate" title="离职时间" :show="show_time2" v-model="newDate" ref="datetimePicker" @confirm="confirmTime2" @cancel="cancel" :formatter="formatter" mode="year-month"></u-datetime-picker>
  25. </view>
  26. </view>
  27. <view class="cell">
  28. <view class="label">工作内容</view>
  29. <u-input v-model="experience.content.job_description" border="none" placeholder="请详细描述你在公司的主要工作内容以及…" suffixIcon="arrow-right"></u-input>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="hflex acenter jcenter">
  34. <view class="save del" @click="del">删除</view>
  35. <view class="save" @click="save">保存</view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import $api from '@/static/js/api.js'
  41. var that = ''
  42. export default {
  43. data() {
  44. return {
  45. experience: {
  46. content: {
  47. company_name: '',
  48. position_name: '',
  49. on_job_start: '',
  50. on_job_end: '',
  51. job_description: '',
  52. }
  53. },
  54. salary_show: false,
  55. birthday_show: false,
  56. work_show: false,
  57. nature_show: false,
  58. show_time1: false,
  59. show_time2: false,
  60. degree_show: false,
  61. education_show: false,
  62. certificate_show: false,
  63. newDate: Number(new Date()),
  64. minDate: new Date('1980-01-01'),
  65. id: ''
  66. }
  67. },
  68. onLoad(options) {
  69. that = this
  70. if(options.id) {
  71. that.id = options.id
  72. that.getData()
  73. }
  74. console.log(that.id);
  75. },
  76. onReady() {
  77. // 微信小程序需要用此写法
  78. this.$refs.datetimePicker.setFormatter(this.formatter)
  79. },
  80. methods: {
  81. getData() {
  82. var pages = getCurrentPages()
  83. var prePage = pages[pages.length - 2]
  84. var experienceList = prePage.$vm.userInfo.work
  85. for(var i=0;i<experienceList.length;i++) {
  86. if(that.id == experienceList[i].id) {
  87. that.experience =experienceList[i]
  88. }
  89. }
  90. console.log(that.experience);
  91. },
  92. // 保存
  93. save() {
  94. uni.showLoading({
  95. title: '上传中',
  96. mask: true
  97. })
  98. if($api.formCheck(that.experience.content.company_name,"required") && $api.formCheck(that.experience.content.position_name,"required") && $api.formCheck(that.experience.content.on_job_start,"required")
  99. && $api.formCheck(that.experience.content.on_job_end,"required") && $api.formCheck(that.experience.content.job_description,"required")) {
  100. var work_experience = {
  101. company_name: that.experience.content.company_name,
  102. position_name: that.experience.content.position_name,
  103. on_job_start: that.experience.content.on_job_start,
  104. on_job_end: that.experience.content.on_job_end,
  105. job_description: that.experience.content.job_description
  106. }
  107. work_experience = JSON.stringify(work_experience)
  108. uni.setStorageSync('work_experience',work_experience)
  109. console.log(that.id);
  110. $api.req({
  111. url: '/data/api.auth.Center/adduppooltalentchild',
  112. method: 'POST',
  113. data: {
  114. id: that.id,
  115. content: work_experience
  116. }
  117. }, function(res) {
  118. uni.hideLoading()
  119. if(res.code == 1) {
  120. /* if(that.id) {
  121. var pages = getCurrentPages()
  122. var prePage = pages[pages.length - 2]
  123. var list = prePage.$vm.userInfo.work
  124. for(var i=0;i<list.length;i++) {
  125. if(list[i].id == that.id) {
  126. list[i].content = work_experience
  127. }
  128. }
  129. prePage.$vm.userInfo.work=list
  130. } else {
  131. var content = {
  132. contetn: work_experience
  133. }
  134. var pages = getCurrentPages()
  135. var prePage = pages[pages.length - 2]
  136. prePage.$vm.userInfo.work.push(content)
  137. } */
  138. $api.info(res.info)
  139. $api.jump(-1)
  140. }
  141. })
  142. } else {
  143. uni.hideLoading()
  144. }
  145. },
  146. del() {
  147. $api.req({
  148. url: '/data/api.auth.Center/delpooltalentchild',
  149. method: 'POST',
  150. data: {
  151. id: that.id
  152. }
  153. }, function(res) {
  154. if(res.code == 1) {
  155. var pages = getCurrentPages()
  156. var prePage = pages[pages.length - 2]
  157. var list = prePage.$vm.userInfo.work
  158. for(var i=0;i<list.length;i++) {
  159. if(list[i].id == that.id) {
  160. list.splice(i,1)
  161. }
  162. }
  163. prePage.$vm.userInfo.work=list
  164. $api.info(res.info)
  165. $api.jump(-1)
  166. }
  167. })
  168. },
  169. // 打开
  170. open(e) {
  171. console.log(e);
  172. switch(e) {
  173. case 'birthday' :
  174. that.birthday_show = true;
  175. break;
  176. case 'work_date' :
  177. that.work_show = true;
  178. break;
  179. case 'salary' :
  180. that.salary_show = true;
  181. break;
  182. case 'work_nature' :
  183. that.nature_show = true;
  184. break;
  185. case 'time1' :
  186. that.show_time1 = true;
  187. break;
  188. case 'time2' :
  189. that.show_time2 = true;
  190. break;
  191. case 'skills_degree' :
  192. that.degree_show = true;
  193. break;
  194. case 'certificate_date' :
  195. that.certificate_show = true;
  196. break;
  197. case 'education' :
  198. that.education_show = true;
  199. break;
  200. }
  201. },
  202. // 格式化日期
  203. formatter(type, value) {
  204. if (type === 'year') {
  205. return `${value}年`
  206. }
  207. if (type === 'month') {
  208. return `${value}月`
  209. }
  210. if (type === 'day') {
  211. return `${value}日`
  212. }
  213. return value
  214. },
  215. // 确定选择生日
  216. confirmAge(e) {
  217. that.base_info.date_birth = $api.formatDate(e)
  218. that.cancel()
  219. },
  220. // 确定选择参加工作时间
  221. confirmWork(e) {
  222. that.base_info.start_working_time = $api.formatDate(e)
  223. that.cancel()
  224. },
  225. confirmSalary(e) {
  226. console.log(e);
  227. var index1 = e.indexs[0]
  228. var index2 = e.indexs[1]
  229. if (index1 - index2 > 2) {
  230. $api.info('请选择正确的薪资范围')
  231. } else {
  232. that.job_inte.salary = e.value[0] + '-' + e.value[1]
  233. that.cancel()
  234. }
  235. },
  236. // 选择工作性质
  237. confirmNature(e) {
  238. console.log(e);
  239. that.job_inte.work_nature = e.value[0]
  240. that.cancel()
  241. },
  242. // 选择在职时间1
  243. confirmTime1(e) {
  244. that.experience.content.on_job_start = $api.formatDate(e)
  245. that.cancel()
  246. },
  247. // 选择在职时间2
  248. confirmTime2(e) {
  249. that.experience.content.on_job_end = $api.formatDate(e)
  250. that.cancel()
  251. },
  252. // 选择技能掌握程度
  253. confirmSkill(e) {
  254. that.skills.skills_degree = e.value[0]
  255. that.cancel()
  256. },
  257. // 选择证书获得时间
  258. confirmDate(e) {
  259. that.certificate.certificate_date = $api.formatDate(e)
  260. that.cancel()
  261. },
  262. /* // 选择学历
  263. changeHandler(e) {
  264. const {
  265. columnIndex,
  266. value,
  267. values, // values为当前变化列的数组内容
  268. index,
  269. // 微信小程序无法将picker实例传出来,只能通过ref操作
  270. picker = this.$refs.uPicker
  271. } = e
  272. console.log(e);
  273. // 当第一列值发生变化时,变化第二列(后一列)对应的选项
  274. if (e.index == 3 || e.index == 4) {
  275. // picker为选择器this实例,变化第二列对应的选项
  276. console.log(this.educationList2);
  277. picker.setColumnValues(1, this.educationList2[0])
  278. }
  279. }, */
  280. // 选择学历
  281. confirmEdu(e) {
  282. console.log(e);
  283. if(e.indexs.length > 1) {
  284. that.base_info.edu = e.value[0]
  285. } else {
  286. that.base_info.edu = e.value[0]
  287. }
  288. that.cancel()
  289. },
  290. // 关闭选择器
  291. cancel() {
  292. that.birthday_show = false
  293. that.work_show = false
  294. that.salary_show = false
  295. that.nature_show = false
  296. that.show_time1 = false
  297. that.show_time2 = false
  298. that.degree_show = false
  299. that.certificate_show = false
  300. that.education_show = false
  301. },
  302. },
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. .content {
  307. background: #F4F4F4;
  308. padding: 20rpx 30rpx 0;
  309. .box {
  310. width: 100%;
  311. background: #FFFFFF;
  312. border-radius: 20rpx;
  313. box-sizing: border-box;
  314. padding: 30rpx 20rpx;
  315. .cell {
  316. width: 100%;
  317. padding: 28rpx 0;
  318. border-bottom: 1rpx solid #F4F4F4;
  319. .label {
  320. font-size: 26rpx;
  321. font-weight: 400;
  322. color: #888888;
  323. padding-bottom: 28rpx;
  324. margin-right: 14rpx;
  325. }
  326. .label_img {
  327. width: 20rpx;
  328. height: 20rpx;
  329. margin: 0 4rpx 0 14rpx;
  330. }
  331. .label2 {
  332. font-size: 20rpx;
  333. font-weight: 400;
  334. color: #B1B1B1;
  335. }
  336. .upload {
  337. width: 200rpx;
  338. height: 200rpx;
  339. background: #F5F5F5;
  340. border-radius: 20rpx;
  341. .text_style1 {
  342. margin-top: 18rpx;
  343. font-size: 24rpx;
  344. font-weight: 400;
  345. color: #ADADAD;
  346. }
  347. }
  348. }
  349. .cell:nth-last-child(1) {
  350. border: none;
  351. }
  352. }
  353. .save {
  354. width: 45%;
  355. height: 84rpx;
  356. background: #506DFF;
  357. border-radius: 42rpx;
  358. font-size: 36rpx;
  359. text-align: center;
  360. margin: 56rpx auto;
  361. font-weight: 500;
  362. color: #FFFFFF;
  363. line-height: 84rpx;
  364. }
  365. .del {
  366. background: #fff;
  367. border: 1rpx solid #506DFF;
  368. color: #506DFF;
  369. margin-right: 40rpx;
  370. }
  371. }
  372. </style>