personal_information.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <template>
  2. <view>
  3. <view class="top">
  4. <view class="avatar" @click="change_avatar(info.avatar)">
  5. <image v-if="info.avatar" :src="info.avatar" mode="aspectFill"></image>
  6. <view class="avatar" v-if="!info.avatar && !info" :style="{backgroundColor:bgColor[1]}">
  7. {{info.name.split('').pop()}}
  8. </view>
  9. </view>
  10. <view class="info">
  11. <view class="name">{{info.name}}</view>
  12. <view class="box">
  13. <view class="item">
  14. <view class="label">部门</view>
  15. <view class="text">{{info.section_fullname}}</view>
  16. </view>
  17. <view class="item">
  18. <view class="label">职务</view>
  19. <view class="text">{{info.duty_num}}</view>
  20. </view>
  21. <view class="item">
  22. <view class="label">员工编号</view>
  23. <view class="text">{{info.staff_num}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="content">
  29. <view class="box">
  30. <view class="item" @click="change_active(1)">
  31. <view class="text" :style="{color:active == 1?'#333':'#8e8e8e'}">个人信息</view>
  32. <view class="line" v-if="active == 1"></view>
  33. </view>
  34. <view class="item" @click="change_active(2)">
  35. <view class="text" :style="{color:active == 2?'#333':'#8e8e8e'}">工作经历</view>
  36. <view class="line" v-if="active == 2"></view>
  37. </view>
  38. <view class="item" @click="change_active(3)">
  39. <view class="text" :style="{color:active == 3?'#333':'#8e8e8e'}">荣誉及证书</view>
  40. <view class="line" v-if="active == 3"></view>
  41. </view>
  42. </view>
  43. <!-- 个人信息 -->
  44. <view class="list_1" v-if="active == 1">
  45. <view class="item" @click="binding_phone()">
  46. <view class="label">手机号</view>
  47. <view class="text">{{info.mobile}}</view>
  48. <view class="right">
  49. <uni-icons type="arrowright"></uni-icons>
  50. </view>
  51. </view>
  52. <view class="item" @click="go_qianming()">
  53. <view class="label">手写签名</view>
  54. <view class="text">
  55. <image :src="info.base_img" style="width: 300rpx;height: 120rpx;" mode="aspectFill"></image>
  56. </view>
  57. <view class="right">
  58. <uni-icons type="arrowright"></uni-icons>
  59. </view>
  60. </view>
  61. <view class="item">
  62. <view class="label">岗位分类</view>
  63. <view class="text">{{info.job_classify}}</view>
  64. <view class="right"></view>
  65. </view>
  66. <view class="item">
  67. <view class="label">岗位</view>
  68. <view class="text">{{info.job}}</view>
  69. <view class="right"></view>
  70. </view>
  71. <view class="item">
  72. <view class="label">职级(职务码)</view>
  73. <view class="text">{{info.duty_num}}</view>
  74. <view class="right"></view>
  75. </view>
  76. <view class="item">
  77. <view class="label">性别</view>
  78. <view class="text" v-if="info.sex == 1">男</view>
  79. <view class="text" v-if="info.sex == 0">女</view>
  80. <view class="right"></view>
  81. </view>
  82. <view class="item">
  83. <view class="label">初始学历</view>
  84. <view class="text">{{info.start_education}}</view>
  85. <view class="right"></view>
  86. </view>
  87. <view class="item">
  88. <view class="label">最高学历</view>
  89. <view class="text">{{info.best_education}}</view>
  90. <view class="right"></view>
  91. </view>
  92. <view class="item">
  93. <view class="label">员工组</view>
  94. <view class="text">{{info.group}}</view>
  95. <view class="right"></view>
  96. </view>
  97. <view class="item">
  98. <view class="label">员工子组</view>
  99. <view class="text">{{info.group_sub}}</view>
  100. <view class="right"></view>
  101. </view>
  102. <view class="item">
  103. <view class="label">籍贯</view>
  104. <view class="text">{{info.native}}</view>
  105. <view class="right"></view>
  106. </view>
  107. <view class="item">
  108. <view class="label">宗教信仰</view>
  109. <view class="text">{{info.faith}}</view>
  110. <view class="right"></view>
  111. </view>
  112. <view class="item">
  113. <view class="label">户口性质</view>
  114. <view class="text">{{info.registered}}</view>
  115. <view class="right"></view>
  116. </view>
  117. <view class="item">
  118. <view class="label">民族</view>
  119. <view class="text">{{info.nation}}</view>
  120. <view class="right"></view>
  121. </view>
  122. <view class="item">
  123. <view class="label">出生日期</view>
  124. <view class="text">{{info.birthday}}</view>
  125. <view class="right"></view>
  126. </view>
  127. <view class="item">
  128. <view class="label">身份证号</view>
  129. <view class="text">{{info.identity_card}}</view>
  130. <view class="right"></view>
  131. </view>
  132. <view class="item">
  133. <view class="label">参加工作时间</view>
  134. <view class="text">{{info.working_date}}</view>
  135. <view class="right"></view>
  136. </view>
  137. <view class="item">
  138. <view class="label">进入神华系统时间</view>
  139. <view class="text">{{info.system_date}}</view>
  140. <view class="right"></view>
  141. </view>
  142. <view class="item">
  143. <view class="label">进入子分公司时间</view>
  144. <view class="text">{{info.system_sub_date}}</view>
  145. <view class="right"></view>
  146. </view>
  147. <view class="item">
  148. <view class="label">进入本单位时间</view>
  149. <view class="text">{{info.section_date}}</view>
  150. <view class="right"></view>
  151. </view>
  152. <view class="item">
  153. <view class="label">政治面貌</view>
  154. <view class="text">{{info.politics}}</view>
  155. <view class="right"></view>
  156. </view>
  157. <view class="item">
  158. <view class="label">参加党派时间</view>
  159. <view class="text">{{info.politics_date}}</view>
  160. <view class="right"></view>
  161. </view>
  162. </view>
  163. <!-- 工作经历 -->
  164. <view class="list_2" v-if="active == 2">
  165. <view class="item">
  166. <view class="text_1">任职时间</view>
  167. <view class="text_2">工作单位</view>
  168. <view class="text_3">职务</view>
  169. </view>
  170. <view class="item" v-for="(item,index) in info.work_experience" :key="index" @click="del_job(index)">
  171. <view class="text_1">{{item.range_text}}</view>
  172. <view class="text_2">{{item.job_unit}}</view>
  173. <view class="text_3">{{item.job_post}}</view>
  174. </view>
  175. <view class="item" @click="add_text()">
  176. <view style="margin: 0 auto;">
  177. <uni-icons type="compose" size="24"></uni-icons>
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 荣誉及证书 -->
  182. <view class="list_3" v-if="active == 3">
  183. <view class="item" v-for="(item,index) in info.honor" :key="index"
  184. @click="click_image(index,item.path)">
  185. <view class="img">
  186. <image :src="item.path" mode="aspectFill"></image>
  187. </view>
  188. <view class="text">{{item.imageName}}</view>
  189. </view>
  190. <view class="item">
  191. <view class="img">
  192. <view class="add" @click="add_image()">+</view>
  193. </view>
  194. <view class="text"></view>
  195. </view>
  196. </view>
  197. </view>
  198. </view>
  199. </template>
  200. <script>
  201. import {set_base_url} from '@/common/set_base_url.js'
  202. export default {
  203. data() {
  204. return {
  205. mine_code:"",
  206. base_url: "",
  207. active: 1,
  208. info: {},
  209. // 头像随机色
  210. bgColor: [],
  211. };
  212. },
  213. onLoad() {
  214. // 初始化当前煤矿编码
  215. this.mine_code = uni.getStorageSync('mine_code')
  216. // 根据矿编码切换首页接口不同的请求基础路径
  217. this.base_url = set_base_url(this.mine_code)
  218. // 设置头像
  219. for (let i = 0; i < 2; i++) {
  220. // 获取随机色
  221. let r = parseInt(Math.random() * 256)
  222. let g = parseInt(Math.random() * 256)
  223. let b = parseInt(Math.random() * 256)
  224. // ES6 字符串拼接
  225. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  226. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  227. // console.log(color)
  228. this.bgColor.push(color)
  229. }
  230. },
  231. onShow() {
  232. this.get_info()
  233. },
  234. methods: {
  235. change_active(index) {
  236. this.active = index
  237. },
  238. // 获取个人信息
  239. get_info() {
  240. this.$api.user_getUinfo({
  241. staff_num: uni.getStorageSync('user').staff_num
  242. }).then((res) => {
  243. // console.log(res.data.data)
  244. this.info = res.data.data
  245. this.info.work_experience = JSON.parse(res.data.data.work_experience)
  246. this.info.honor = JSON.parse(res.data.data.honor)
  247. })
  248. },
  249. // 新增工作经历
  250. add_text() {
  251. const data = {
  252. work_experience: this.info.work_experience
  253. }
  254. uni.navigateTo({
  255. url: "./job_record/job_record",
  256. success: (res) => {
  257. // 通过eventChannel向被打开页面传送数据
  258. res.eventChannel.emit('acceptDataFromOpenerPage', {
  259. data: data
  260. })
  261. }
  262. })
  263. },
  264. del_job(index) {
  265. uni.showActionSheet({
  266. itemList: ['删除'],
  267. success: (res) => {
  268. this.info.work_experience.splice(index, 1)
  269. this.$api.user_updateUserMessage({
  270. work_experience: JSON.stringify(this.info.work_experience)
  271. }).then((res) => {
  272. console.log(res)
  273. uni.showToast({
  274. icon: "none",
  275. title: "删除成功"
  276. })
  277. })
  278. },
  279. fail: (res) => {
  280. console.log(res.errMsg);
  281. }
  282. });
  283. },
  284. // 新增荣誉
  285. add_image() {
  286. const data = {
  287. base_url: this.base_url,
  288. honor_list: this.info.honor
  289. }
  290. uni.navigateTo({
  291. url: "./honor/honor",
  292. success: (res) => {
  293. // 通过eventChannel向被打开页面传送数据
  294. res.eventChannel.emit('acceptDataFromOpenerPage', {
  295. data: data
  296. })
  297. }
  298. })
  299. },
  300. click_image(index, path) {
  301. console.log(index, path)
  302. uni.showActionSheet({
  303. itemList: ['查看', '删除'],
  304. success: (res) => {
  305. if (res.tapIndex == 0) {
  306. console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  307. uni.previewImage({
  308. urls: path.split(','),
  309. });
  310. } else if (res.tapIndex == 1) {
  311. console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  312. console.log(index)
  313. this.info.honor.splice(index, 1)
  314. console.log(this.info.honor)
  315. this.$api.user_updateUserMessage({
  316. honor: JSON.stringify(this.info.honor)
  317. }).then((res) => {
  318. console.log(res)
  319. uni.showToast({
  320. icon: "none",
  321. title: "删除成功"
  322. })
  323. })
  324. }
  325. },
  326. fail: (res) => {
  327. console.log(res.errMsg);
  328. }
  329. })
  330. },
  331. // 更换头像
  332. change_avatar() {
  333. uni.showActionSheet({
  334. itemList: ['更换头像'],
  335. success: (res) => {
  336. uni.chooseImage({
  337. count: 1,
  338. success: (chooseImageRes) => {
  339. const tempFilePaths = chooseImageRes.tempFilePaths;
  340. console.log(chooseImageRes.tempFiles[0]);
  341. uni.showLoading({
  342. mask: true,
  343. title: "上传中..."
  344. })
  345. uni.uploadFile({
  346. url: this.base_url + "/worksheet/design/up_images",
  347. header: {
  348. 'Authorization': uni.getStorageSync('token_type') +' '+uni.getStorageSync('Authorization')
  349. },
  350. filePath: tempFilePaths[0],
  351. name: 'file',
  352. // formData只有H5存在
  353. formData: {
  354. image: chooseImageRes.tempFiles[0]
  355. },
  356. success: (uploadFileRes) => {
  357. console.log(JSON.parse(uploadFileRes.data));
  358. const data = JSON.parse(uploadFileRes.data).data
  359. if (!this.info.avatar) {
  360. this.info.avatar = data.path
  361. } else {
  362. this.info.avatar = data.path
  363. }
  364. console.log(this.info.avatar)
  365. this.$api.user_updateUserMessage({
  366. avatar: this.info.avatar
  367. }).then((res) => {
  368. console.log(res)
  369. uni.hideLoading()
  370. uni.showToast({
  371. icon: "none",
  372. title: "更换成功"
  373. })
  374. })
  375. }
  376. })
  377. }
  378. })
  379. },
  380. fail: (res) => {
  381. console.log(res.errMsg);
  382. }
  383. })
  384. },
  385. // 绑定手机
  386. binding_phone(){
  387. uni.navigateTo({
  388. url:"../setPhone/setPhone"
  389. })
  390. },
  391. go_qianming(){
  392. uni.navigateTo({
  393. url:"../signature/signature"
  394. })
  395. }
  396. }
  397. }
  398. </script>
  399. <style lang="scss">
  400. page {
  401. background-color: #F5F8F8;
  402. }
  403. .top {
  404. position: relative;
  405. background-color: #FFFFFF;
  406. width: 750rpx;
  407. height: 490rpx;
  408. background-image: url(./icon/top.png);
  409. background-size: 100% 100%;
  410. background-position: 0 -110rpx;
  411. background-repeat: no-repeat;
  412. .avatar {
  413. padding-top: 70rpx;
  414. text-align: center;
  415. image {
  416. width: 200rpx;
  417. height: 200rpx;
  418. border-radius: 50%;
  419. }
  420. }
  421. .info {
  422. margin-top: 20rpx;
  423. .name {
  424. text-align: center;
  425. font-size: 40rpx;
  426. font-weight: 700;
  427. }
  428. .box {
  429. margin-top: 30rpx;
  430. display: flex;
  431. justify-content: space-around;
  432. .item {
  433. width: 250rpx;
  434. text-align: center;
  435. .label {
  436. font-size: 30rpx;
  437. color: #009FE8;
  438. margin-bottom: 10rpx;
  439. }
  440. .text {
  441. font-size: 32rpx;
  442. }
  443. }
  444. }
  445. }
  446. .redo {
  447. width: 100rpx;
  448. height: 100rpx;
  449. line-height: 100rpx;
  450. text-align: center;
  451. position: absolute;
  452. top: 0;
  453. right: 0;
  454. }
  455. margin-bottom: 20rpx;
  456. }
  457. .content {
  458. background-color: #FFFFFF;
  459. .box {
  460. display: flex;
  461. justify-content: space-around;
  462. align-items: center;
  463. border-bottom: 2rpx solid #F5F8F8;
  464. .item {
  465. height: 95rpx;
  466. width: 230rpx;
  467. text-align: center;
  468. position: relative;
  469. .text {
  470. font-size: 34rpx;
  471. line-height: 95rpx;
  472. }
  473. .line {
  474. margin: -6rpx auto 0;
  475. width: 80rpx;
  476. height: 6rpx;
  477. background-color: #009FE8;
  478. }
  479. }
  480. }
  481. .list_1 {
  482. box-sizing: border-box;
  483. padding: 0 50rpx;
  484. .item {
  485. border-bottom: 2rpx solid #F5F8F8;
  486. // height: 95rpx;
  487. box-sizing: border-box;
  488. padding: 30rpx 0;
  489. display: flex;
  490. // justify-content: space-between;
  491. justify-content: space-between;
  492. align-items: center;
  493. font-size: 32rpx;
  494. .label {
  495. width: 300rpx;
  496. text-align: left;
  497. }
  498. .text {
  499. width: 300rpx;
  500. text-align: left;
  501. color: #8e8e8e;
  502. }
  503. .right {
  504. // width: 100rpx;
  505. text-align: right;
  506. }
  507. }
  508. }
  509. .list_2 {
  510. box-sizing: border-box;
  511. padding: 0 50rpx;
  512. .item {
  513. border-bottom: 2rpx solid #F5F8F8;
  514. // height: 95rpx;
  515. box-sizing: border-box;
  516. padding: 20rpx 0;
  517. display: flex;
  518. justify-content: space-between;
  519. align-items: center;
  520. font-size: 28rpx;
  521. text-align: center;
  522. color: #8e8e8e;
  523. .text_1 {
  524. width: 190rpx;
  525. }
  526. .text_2 {
  527. width: 240rpx;
  528. }
  529. .text_3 {
  530. width: 160rpx;
  531. }
  532. }
  533. .item:first-child {
  534. font-size: 32rpx;
  535. color: #333;
  536. }
  537. }
  538. .list_3 {
  539. box-sizing: border-box;
  540. padding: 50rpx;
  541. overflow: hidden;
  542. .item {
  543. float: left;
  544. margin-right: 50rpx;
  545. margin-bottom: 30rpx;
  546. width: 300rpx;
  547. text-align: center;
  548. .img {
  549. margin-bottom: 10rpx;
  550. image {
  551. width: 300rpx;
  552. height: 180rpx;
  553. }
  554. .add {
  555. font-size: 140rpx;
  556. color: #DCDCDC;
  557. text-align: center;
  558. height: 180rpx;
  559. line-height: 160rpx;
  560. background-color: #EEEEEE;
  561. }
  562. }
  563. .text {
  564. width: 260rpx;
  565. font-size: 30rpx;
  566. color: #8e8e8e;
  567. overflow: hidden;
  568. white-space: nowrap;
  569. text-overflow: ellipsis;
  570. }
  571. }
  572. .item:nth-child(2n) {
  573. margin-right: 0;
  574. }
  575. }
  576. }
  577. </style>