changeMessage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <template>
  2. <view class="">
  3. <view class="navbar">
  4. <view class="back">
  5. <text class="iconfont icon-fanhui " @click="backLast()"></text>
  6. </view>
  7. <text>修改个人信息</text>
  8. </view>
  9. <view class="change-home">
  10. <uni-forms :value="formData" ref="form">
  11. <view class="form-list">
  12. <view class="form-table">
  13. <view class="form-left">
  14. 姓名:
  15. </view>
  16. <input type="text" v-model="formData.true_name" placeholder="请输入姓名" class="input" />
  17. </view>
  18. <view class="form-table">
  19. <view class="form-left">
  20. 学号:
  21. </view>
  22. <input type="number" v-model="formData.no" placeholder="请输入学号" class="input"
  23. @blur="rulesNo()" />
  24. </view>
  25. </view>
  26. <view class="form-list">
  27. <view class="form-table">
  28. <view class="form-left">
  29. 入学日期:
  30. </view>
  31. <picker mode="date" :value="formData.enrol_date" @change="enterDateChange" class="input1">
  32. <view class="uni-input">{{formData.enrol_date}} </view>
  33. </picker>
  34. </view>
  35. <view class="form-table">
  36. <view class="form-left">
  37. 出生日期:
  38. </view>
  39. <picker mode="date" :value="formData.birthday" @change="birthDateChange" class="input1">
  40. <view class="uni-input">{{formData.birthday}}</view>
  41. </picker>
  42. </view>
  43. <view class="form-table">
  44. <view class="form-left">
  45. 性别:
  46. </view>
  47. <picker mode="selector" :range="sex" :range-key="'label'" @change="sexChange" class="input1"
  48. :value="formData.sex">
  49. <view class="uni-input">{{sex[formData.sex].label}}</view>
  50. </picker>
  51. </view>
  52. <view class="form-table">
  53. <view class="form-left">
  54. 民族:
  55. </view>
  56. <picker mode="selector" :range="nation" :range-key="'label'" @change="nationChange"
  57. class="input1" :value="formData.nation">
  58. <view class="uni-input">{{nation[formData.nation].label}}</view>
  59. </picker>
  60. </view>
  61. </view>
  62. <view class="form-list">
  63. <view class="form-table">
  64. <view class="form-left">
  65. 身份证号:
  66. </view>
  67. <input type="idcard" v-model="formData.id_card" placeholder="请输身份证号" class="input"
  68. @blur='idcardRule()' />
  69. </view>
  70. <view class="form-table">
  71. <view class="form-left">
  72. 手机号:
  73. </view>
  74. <input type="number" v-model="formData.mobile" placeholder="请输入手机号" class="input"
  75. @blur='mobileRule()' />
  76. </view>
  77. <view class="form-table">
  78. <view class="form-left">
  79. 电子邮箱:
  80. </view>
  81. <input type="text" v-model="formData.email" placeholder="请输入电子邮箱" class="input"
  82. @blur='emailRule()' />
  83. </view>
  84. <view class="form-table">
  85. <view class="form-left">
  86. 邮政编码:
  87. </view>
  88. <input type="text" v-model="formData.code" placeholder="请输入邮政编码" class="input" />
  89. </view>
  90. </view>
  91. <view class="form-list">
  92. <!-- <view class="title">
  93. 其他信息
  94. </view> -->
  95. <view class="address-border">
  96. <view class="name">
  97. 籍贯(X省X县)
  98. </view>
  99. <view class="address">
  100. <input type="text" v-model="formData.native_place" placeholder="请输入籍贯" class="input" />
  101. </view>
  102. </view>
  103. <view class="address-border">
  104. <view class="name">
  105. 家庭地址
  106. </view>
  107. <view class="address">
  108. <input type="text" class="input" v-model="formData.address"
  109. placeholder="请输入家庭住址"></textarea>
  110. </view>
  111. </view>
  112. <view class="address-border">
  113. <view class="name">
  114. 户口所在地派出所
  115. </view>
  116. <view class="address">
  117. <input type="text" class="input" v-model="formData.local_police_station"
  118. placeholder="请输入户口所在地派出所"></textarea>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- 各个阶段日期 -->
  123. <!-- <view class="title">
  124. 阶段日期
  125. </view> -->
  126. <view class="form-list">
  127. <view class="form-table">
  128. <view class="form-left">
  129. 申请入党日期:
  130. </view>
  131. <picker mode="date" :value="formData.join_party_date" @change="joinPartyChange" class="input1">
  132. <view class="uni-input">{{formData.join_party_date ? formData.join_party_date:'请选择'}}
  133. </view>
  134. </picker>
  135. </view>
  136. <view class="form-table">
  137. <view class="form-left1">
  138. 积极分子党课结业日期:
  139. </view>
  140. <picker mode="date" :value="formData.complete_party_date" @change="completePartyChange"
  141. class="input1">
  142. <view class="uni-input">
  143. {{formData.complete_party_date ? formData.complete_party_date:'请选择'}}</view>
  144. </picker>
  145. </view>
  146. <view class="form-table">
  147. <view class="form-left">
  148. 积极分子日期:
  149. </view>
  150. <picker mode="date" :value="formData.join_activist_date" @change="activistChange"
  151. class="input1">
  152. <view class="uni-input">{{formData.join_activist_date ? formData.join_activist_date:'请选择'}}
  153. </view>
  154. </picker>
  155. </view>
  156. <view class="form-table">
  157. <view class="form-left">
  158. 发展对象日期:
  159. </view>
  160. <picker mode="date" :value="formData.join_fzdx_date" @change="fzdxChange" class="input1">
  161. <view class="uni-input">{{formData.join_fzdx_date ? formData.join_fzdx_date:'请选择'}}</view>
  162. </picker>
  163. </view>
  164. <view class="form-table">
  165. <view class="form-left1">
  166. 发展对象党课结业日期:
  167. </view>
  168. <picker mode="date" :value="formData.complete_fzdx_party_date" @change="completefzdxChange"
  169. class="input1">
  170. <view class="uni-input">
  171. {{formData.complete_fzdx_party_date ? formData.complete_fzdx_party_date:'请选择'}}</view>
  172. </picker>
  173. </view>
  174. <view class="form-table">
  175. <view class="form-left">
  176. 预备党员日期:
  177. </view>
  178. <picker mode="date" :value="formData.join_ybdy_date" @change="ybdyChange" class="input1">
  179. <view class="uni-input">{{formData.join_ybdy_date ? formData.join_ybdy_date:'请选择'}}</view>
  180. </picker>
  181. </view>
  182. <view class="form-table">
  183. <view class="form-left">
  184. 党员转正日期:
  185. </view>
  186. <picker mode="date" :value="formData.join_zsdy_date" @change="zsdyChange" class="input1">
  187. <view class="uni-input">{{formData.join_zsdy_date ? formData.join_zsdy_date:'请选择' }}</view>
  188. </picker>
  189. </view>
  190. </view>
  191. <!-- ? -->
  192. <button @click="submitForm" class="submit">保存修改</button>
  193. </uni-forms>
  194. </view>
  195. </view>
  196. </template>
  197. <script>
  198. import navBar from '../../components/navBar/navbar.vue';
  199. var app = getApp()
  200. export default {
  201. components: {
  202. navBar
  203. },
  204. data() {
  205. return {
  206. sex: [{
  207. value: 0,
  208. label: "请选择性别"
  209. },
  210. {
  211. value: 1,
  212. label: "男"
  213. },
  214. {
  215. value: 2,
  216. label: "女"
  217. }
  218. ],
  219. sexIndex: "",
  220. nationIndex: "",
  221. nation: [{
  222. value: '',
  223. label: ''
  224. }],
  225. formData: {
  226. true_name: "",
  227. no: "",
  228. politics_status: "",
  229. nation: 0,
  230. sex: 0,
  231. },
  232. join_zsdy_date: "请选择转正日期",
  233. enterDate: "请选择入学日期",
  234. birthDate: "请选择出生日期",
  235. name: "",
  236. }
  237. },
  238. created() {
  239. uni.showLoading()
  240. this.getUserInfo()
  241. let userInfo = uni.getStorageSync('userInfo')
  242. let that = this
  243. setTimeout(function() {
  244. app.request('/develop/http-status', '', 'get').then(res => {
  245. let allStatus = res.data.data
  246. let nation = allStatus["App\\Repositories\\Enums\\NationEnum"];
  247. let arr = []
  248. for (let i in nation) {
  249. arr.push({
  250. value: Number(i),
  251. label: nation[i]
  252. });
  253. }
  254. that.nation =arr
  255. that.formData.nation = uni.getStorageSync('userInfo').nation
  256. uni.hideLoading()
  257. })
  258. }, 500)
  259. },
  260. methods: {
  261. getUserInfo() {
  262. app.request('/staff-me', '', 'get').then(res => {
  263. console.log(res.data.data, '---------------------个人信息')
  264. this.formData= res.data.data
  265. uni.setStorageSync('userInfo', res.data.data)
  266. })
  267. },
  268. backLast: function() {
  269. console.log(this.url)
  270. uni.reLaunch({
  271. url: './index'
  272. })
  273. },
  274. idcardRule: function() {
  275. var rule = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  276. if (!rule.test(this.formData.id_card)) {
  277. uni.showToast({
  278. title: '身份证号格式错误~',
  279. icon: 'none'
  280. })
  281. }
  282. },
  283. mobileRule: function() {
  284. var rule = /^1[0-9]{10}$/;
  285. if (!rule.test(this.formData.mobile)) {
  286. uni.showToast({
  287. title: '手机号格式错误~',
  288. icon: 'none'
  289. })
  290. }
  291. },
  292. emailRule: function() {
  293. var rule = /^([A-z0-9]{6,18})(\w|\-)+@[A-z0-9]+\.([A-z]{2,3})$/;
  294. if (!rule.test(this.formData.email)) {
  295. uni.showToast({
  296. title: '邮箱格式错误~',
  297. icon: 'none'
  298. })
  299. }
  300. },
  301. submitForm(form) {
  302. // 手动提交表单
  303. // this.$refs.form.submit().then((res) => {
  304. // console.log('表单返回得值:', res)
  305. // })
  306. if (!this.formData.birthday) {
  307. uni.showToast({
  308. title: '请选择出生日期~',
  309. icon: 'none'
  310. })
  311. } else if (!this.formData.class) {
  312. uni.showToast({
  313. title: '请选择班级~',
  314. icon: 'none'
  315. })
  316. } else if (!this.formData.enrol_date) {
  317. uni.showToast({
  318. title: '请选择入学日期级~',
  319. icon: 'none'
  320. })
  321. } else if (!this.formData.mobile) {
  322. uni.showToast({
  323. title: '请输入手机号~',
  324. icon: 'none'
  325. })
  326. } else if (!this.formData.id_card) {
  327. uni.showToast({
  328. title: '请输入身份证号~',
  329. icon: 'none'
  330. })
  331. } else if (!this.formData.nation) {
  332. uni.showToast({
  333. title: '请选择民族~',
  334. icon: 'none'
  335. })
  336. } else if (!this.formData.native_place) {
  337. uni.showToast({
  338. title: '请输入籍贯~',
  339. icon: 'none'
  340. })
  341. } else if (!this.formData.address) {
  342. uni.showToast({
  343. title: '请输入家庭地址~',
  344. icon: 'none'
  345. })
  346. } else if (!this.formData.id_card) {
  347. uni.showToast({
  348. title: '请输入户口所在地派出所~',
  349. icon: 'none'
  350. })
  351. } else {
  352. app.request('/staffs/' + this.formData.id, this.formData, 'put').then(res => {
  353. if (res.data.code == 200) {
  354. uni.showToast({
  355. title: "修改成功",
  356. icon: 'none',
  357. success: () => {
  358. app.request('/staff-me', '', 'get').then(res => {
  359. uni.setStorageSync('userInfo', res.data.data)
  360. })
  361. }
  362. })
  363. setTimeout(function() {
  364. uni.switchTab({
  365. url: '../index/index'
  366. })
  367. }, 500)
  368. } else {
  369. uni.showToast({
  370. title: res.data.message,
  371. icon: 'none'
  372. })
  373. }
  374. })
  375. }
  376. },
  377. enterDateChange: function(e) {
  378. this.formData.enrol_date = e.detail.value
  379. },
  380. birthDateChange: function(e) {
  381. this.formData.birthday = e.detail.value
  382. },
  383. joinPartyChange: function(e) {
  384. this.formData.join_party_date = e.detail.value
  385. },
  386. completePartyChange: function(e) {
  387. this.formData.complete_party_date = e.detail.value
  388. },
  389. activistChange: function(e) {
  390. this.formData.join_activist_date = e.detail.value
  391. },
  392. fzdxChange: function(e) {
  393. this.formData.join_fzdx_date = e.detail.value
  394. },
  395. completefzdxChange(e) {
  396. this.formData.complete_fzdx_party_date = e.detail.value
  397. },
  398. ybdyChange: function(e) {
  399. console.log(e, '--------------------')
  400. this.formData.join_ybdy_date = e.detail.value
  401. },
  402. zsdyChange: function(e) {
  403. this.formData.join_zsdy_date = e.detail.value
  404. this.join_zsdy_date = e.detail.value
  405. },
  406. sexChange: function(e) {
  407. let index = e.detail.value
  408. this.sexIndex = e.detail.value
  409. this.formData.sex = e.detail.value
  410. console.log(e.detail.value)
  411. console.log(this.sex)
  412. },
  413. nationChange: function(e) {
  414. let index = e.detail.value
  415. this.nationIndex = index
  416. this.formData.nation = e.detail.value
  417. console.log(this.nation[e.detail.value].value)
  418. console.log(this.formData.nation)
  419. }
  420. }
  421. }
  422. </script>
  423. <style lang="scss">
  424. page {
  425. background-color: #f4f4f4;
  426. }
  427. .title {
  428. padding-left: 30upx;
  429. font-size: 30upx;
  430. margin-top: 30upx;
  431. color: #424242;
  432. // line-height: 70upx;
  433. }
  434. .navbar {
  435. font-size: 32upx;
  436. height: 100upx;
  437. line-height: 100upx;
  438. color: #888888;
  439. position: relative;
  440. position: fixed;
  441. top: 0;
  442. z-index: 9999999;
  443. width: 100%;
  444. background-color: #FFFFFF;
  445. text-align: center;
  446. border-bottom: solid 2upx #EFF1F6;
  447. .back {
  448. height: 100upx;
  449. width: 100upx;
  450. text-align: center;
  451. // background-color: #007AFF;
  452. position: absolute;
  453. float: left;
  454. left: 0upx;
  455. font-size: 32upx;
  456. }
  457. }
  458. .change-home {
  459. // height: 100vh;
  460. padding-bottom: 50upx;
  461. padding-top: 100upx;
  462. .xing {
  463. color: #e61916;
  464. font-size: 30upx;
  465. margin-right: 5upx;
  466. }
  467. .form-list {
  468. background-color: #FFFFFF;
  469. padding: 10upx 30upx 30upx;
  470. width: 85%;
  471. margin: 0 auto;
  472. margin-top: 30upx;
  473. box-shadow: 2px 2px 5px #d5d5d5;
  474. border-radius: 12upx;
  475. .form-table {
  476. display: flex;
  477. height: 90upx;
  478. font-size: 30upx;
  479. border-bottom: solid 2upx #f0f0f0;
  480. .form-left {
  481. font-size: 28upx;
  482. flex: 0 0 180upx;
  483. height: 90upx;
  484. color: #afafaf;
  485. line-height: 90upx;
  486. }
  487. .form-left1 {
  488. font-size: 28upx;
  489. // flex: 0 0 180upx;
  490. height: 90upx;
  491. color: #afafaf;
  492. line-height: 90upx;
  493. }
  494. .input,
  495. .input1 {
  496. flex: 1;
  497. padding: 0 10upx;
  498. height: 90upx;
  499. line-height: 90upx;
  500. font-size: 28upx;
  501. color: #232323;
  502. }
  503. .input1 {
  504. background-image: url(../../static/images/down.png);
  505. background-size: 30upx;
  506. background-position: 98%;
  507. background-repeat: no-repeat;
  508. }
  509. }
  510. .title {
  511. font-size: 24upx;
  512. color: #e61916;
  513. }
  514. .left-icon {
  515. color: #e61916;
  516. margin-right: 10upx;
  517. }
  518. // .input {
  519. // // background-color: #007AFF;
  520. // padding: 10upx;
  521. // height: 26px;
  522. // line-height: 30px;
  523. // font-size: 28upx;
  524. // color: #888888;
  525. // }
  526. }
  527. .address-border {
  528. padding: 30upx 0;
  529. border-bottom: solid 2upx #f0f0f0;
  530. }
  531. .name {
  532. font-size: 24upx;
  533. height: 50upx;
  534. color: #afafaf;
  535. line-height: 50upx;
  536. background-color: #FFFFFF;
  537. // border-bottom: solid 2upx #f0f0f0;
  538. }
  539. .address {
  540. .input {
  541. flex: 1;
  542. height: 50upx;
  543. line-height: 50upx;
  544. font-size: 28upx;
  545. color: #232323;
  546. }
  547. }
  548. .submit {
  549. margin-top: 60upx;
  550. width: 60%;
  551. color: #FFFFFF;
  552. background-color: #e61916;
  553. font-size: 30upx;
  554. margin-bottom: 100upx;
  555. }
  556. }
  557. </style>