applyEducationCode.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <!-- 退役军人职业教育码申请 -->
  2. <template>
  3. <view class="apply-code">
  4. <u-navbar back-text="" title="" back-icon-color="#FFFFFF" :background="{ background: '#3D5D4C' }"
  5. :border-bottom="false" :custom-back="customBack"></u-navbar>
  6. <u-form :model="form" ref="uForm" label-width="160" label-align="left">
  7. <u-form-item label="姓名:" prop="veteName" :required="true">
  8. <u-input v-model="form.veteName" placeholder="请输入真实姓名" />
  9. </u-form-item>
  10. <u-form-item label="身份证号:" prop="veteIdCard" :required="true">
  11. <u-input v-model="form.veteIdCard" placeholder="请输入身份证号" @blur="idNumberChange" maxlength="18" />
  12. </u-form-item>
  13. <u-form-item label="性别:" prop="veteSex" :required="true">
  14. <u-input v-model="form.veteSex" placeholder="输入身份证自动获取" disabled />
  15. </u-form-item>
  16. <u-form-item label="民族:" prop="nation">
  17. <u-input v-model="form.nation" placeholder="请输入您的民族" />
  18. </u-form-item>
  19. <u-form-item label="所在区域:" prop="veteHousehArea" :required="true">
  20. <u-input v-model="form.veteHousehArea" placeholder="请选择您的户籍区域" type="select" @click="areaShow = true" />
  21. </u-form-item>
  22. <u-form-item label="现家庭详细地址:" label-position="top" label-width="200" label-align="left"
  23. prop="veteResiAddress" :required="true">
  24. <u-input v-model="form.veteResiAddress" placeholder="请输入您的现家庭详细地址" />
  25. </u-form-item>
  26. <u-form-item label="户籍类别:" prop="houseTypeId">
  27. <u-radio-group v-model="form.houseTypeId" @change="houseTypeChange">
  28. <u-radio v-for="(item, index) in houseTypeList" :key="index" :name="item.value">
  29. {{ item.label }}
  30. </u-radio>
  31. </u-radio-group>
  32. </u-form-item>
  33. <u-form-item label="户籍地:" prop="veteHousehRegi">
  34. <u-input v-model="form.veteHousehRegi" placeholder="请选择您的户籍地" type="select" @click="regionClick" />
  35. </u-form-item>
  36. <u-form-item label="文化程度:" prop="degrEduc" :required="true">
  37. <u-input v-model="form.degrEduc" placeholder="请选择您的文化程度" type="select" @click="degrEducShow = true" />
  38. </u-form-item>
  39. <u-form-item label="政治面貌:" prop="politOutlook" :required="true">
  40. <u-input v-model="form.politOutlook" placeholder="请选择您的政治面貌" type="select"
  41. @click="politOutlookShow = true" />
  42. </u-form-item>
  43. <u-form-item label="就业状况:" prop="jobStatus">
  44. <u-radio-group v-model="form.jobStatus">
  45. <u-radio v-for="(item, index) in employmentStatusList" :key="index" :name="item.value">
  46. {{ item.label }}
  47. </u-radio>
  48. </u-radio-group>
  49. </u-form-item>
  50. <u-form-item label="薪资范围:" prop="salaryRangeName">
  51. <u-input v-model="form.salaryRangeName" placeholder="请选择您的薪资范围" type="select"
  52. @click="salaryRangeShow = true" />
  53. </u-form-item>
  54. <u-form-item label="QQ:" prop="qqNum">
  55. <u-input v-model="form.qqNum" placeholder="请输入您的QQ" />
  56. </u-form-item>
  57. <u-form-item label="微信:" prop="wxNum">
  58. <u-input v-model="form.wxNum" placeholder="请输入您的微信" />
  59. </u-form-item>
  60. <u-form-item label="近期1寸免冠照片:" label-position="top" label-width="200" label-align="left" :required="true">
  61. <view class="pic">
  62. <u-upload ref="uUpload" :action="action" :custom-btn="true" :header="{
  63. 'Authorization': `Bearer ${vuex_token}`
  64. }" :max-count="1" :limitType="['png', 'jpg']" @on-success="uploadSuccess" @on-remove="uploadRemove">
  65. <view class="pic-upload-box" slot="addBtn">
  66. <view class="pic-upload">
  67. <image src="../../static/img/upload-add.png" mode="" />
  68. <view class="font">上传照片</view>
  69. </view>
  70. <view class="tips">支持jpg.png格式</view>
  71. </view>
  72. </u-upload>
  73. <!-- <view class="pic-photograph" @click="photograph">
  74. <image src="../../static/img/paizhao.png" mode=""></image>
  75. <view class="font">立即拍照</view>
  76. </view> -->
  77. <!-- <view class="pic-url" v-if="form.files.length > 0">
  78. <view class="icon">
  79. <u-icon name="close" color="#fff" size="16" @click="clearFile"></u-icon>
  80. </view>
  81. <image :src="form.files[0].filesUrl" mode=""/>
  82. </view> -->
  83. </view>
  84. </u-form-item>
  85. <u-form-item>
  86. <u-button type="primary" class="submit" @click="submit">提交</u-button>
  87. </u-form-item>
  88. </u-form>
  89. <!-- 文化程度下拉 -->
  90. <u-select v-model="degrEducShow" :list="degrEducList" @confirm="degrEducChange"
  91. :default-value="degrEducIndex" />
  92. <!-- 政治面貌下拉 -->
  93. <u-select v-model="politOutlookShow" :list="politOutlookList" @confirm="politOutlookChange"
  94. :default-value="politOutlookIndex" />
  95. <!-- 户籍地下拉 -->
  96. <city-select-province v-model="regionShow" :default-region="[]" @city-change="regionConfirm" />
  97. <!-- 户籍区域下拉 -->
  98. <u-city-select v-model="areaShow" :default-region="[]" @city-change="areaConfirm" />
  99. <!-- 工资范围下拉 -->
  100. <u-select v-model="salaryRangeShow" :list="salaryRangeList" @confirm="salaryRangeChange"
  101. :default-value="salaryRangeIndex" />
  102. </view>
  103. </template>
  104. <script>
  105. import citySelectProvince from '../../uview-ui/components/u-city-select-province/u-city-select-province.vue'
  106. export default {
  107. components: {
  108. citySelectProvince
  109. },
  110. data() {
  111. return {
  112. // 上传地址
  113. action: this.config.uploadUrl,
  114. form: {
  115. veteName: '',
  116. veteIdCard: '',
  117. veteSex: '',
  118. nation: '',
  119. qqNum: '',
  120. wxNum: '',
  121. degrEduc: '',
  122. degrEducId: '',
  123. houseType: '',
  124. houseTypeId: '',
  125. politOutlook: '',
  126. politOutlookId: '',
  127. veteHousehRegi: '',
  128. veteHousehArea: '',
  129. veteResiAddress: '',
  130. veteDateBirth: '',
  131. veteStatus: '1',
  132. files: [],
  133. jobStatus: '',
  134. salaryRange: '',
  135. salaryRangeName: '',
  136. provinceId: '',
  137. provinceName: '',
  138. cityId: '',
  139. cityName: '',
  140. areaId: '',
  141. areaName: ''
  142. },
  143. // 表单验证
  144. rules: {
  145. veteName: [{
  146. required: true,
  147. message: '请输入姓名',
  148. trigger: ['change', 'blur']
  149. }],
  150. veteIdCard: [{
  151. required: true,
  152. pattern: /(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/,
  153. // 正则检验前先将值转为字符串
  154. transform(value) {
  155. return String(value);
  156. },
  157. message: '请正确输入身份证号',
  158. trigger: ['change', 'blur']
  159. }],
  160. vetePhone: [{
  161. pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
  162. message: '请正确输入手机号',
  163. required: true,
  164. trigger: ['change', 'blur'],
  165. }],
  166. veteHousehArea: [{
  167. required: true,
  168. message: '请选择户籍区域',
  169. trigger: ['change', 'blur'],
  170. }],
  171. veteResiAddress: [{
  172. required: true,
  173. message: '请填写详细地址',
  174. trigger: ['change', 'blur'],
  175. }],
  176. // nation:[
  177. // {
  178. // required: true,
  179. // message: '请填写民族',
  180. // trigger: ['change', 'blur'],
  181. // }
  182. // ],
  183. degrEduc: [{
  184. required: true,
  185. message: '请选择文化程度',
  186. trigger: ['change', 'blur'],
  187. }],
  188. politOutlook: [{
  189. required: true,
  190. message: '请选择政治面貌',
  191. trigger: ['change', 'blur']
  192. }],
  193. // houseTypeId:[
  194. // {
  195. // required: true,
  196. // message: '请选择户籍类别',
  197. // trigger: ['change', 'blur']
  198. // }
  199. // ],
  200. // salaryRangeName: [
  201. // {
  202. // required: true,
  203. // message: '请选择薪资范围',
  204. // trigger: ['change', 'blur']
  205. // }
  206. // ],
  207. // jobStatus: [
  208. // {
  209. // required: true,
  210. // message: '请选择就业状态',
  211. // trigger: ['change', 'blur']
  212. // }
  213. // ]
  214. },
  215. // 文化程度
  216. degrEducShow: false,
  217. degrEducList: [],
  218. degrEducIndex: [],
  219. // 政治面貌
  220. politOutlookShow: false,
  221. politOutlookList: [],
  222. politOutlookIndex: [],
  223. // 户籍地
  224. regionShow: false,
  225. regionDefault: [],
  226. // 户籍类型
  227. houseTypeShow: false,
  228. houseTypeList: [],
  229. houseTypeIndex: [],
  230. // 户籍区域
  231. areaShow: false,
  232. // 薪资范围
  233. salaryRangeShow: false,
  234. salaryRangeIndex: [],
  235. salaryRangeList: [],
  236. salaryRangeIndex: [],
  237. // 就业状态
  238. employmentStatusList: []
  239. }
  240. },
  241. onLoad() {
  242. this.form.vetePhone = this.vuex_user.mobile;
  243. this.getVeteDegrEduc();
  244. this.getVetePolitOutlook();
  245. this.getVeteHouseType();
  246. this.getSalaryRange();
  247. this.getEmploymentStatus();
  248. this.getVeteEducData();
  249. },
  250. onReady() {
  251. this.$refs.uForm.setRules(this.rules);
  252. },
  253. methods: {
  254. customBack() {
  255. const pages = getCurrentPages();
  256. if (pages.length >= 2) {
  257. uni.setStorageSync('last_page', pages[pages.length - 2].route);
  258. if (pages[pages.length - 2].options) {
  259. uni.setStorageSync(
  260. 'last_page_options',
  261. pages[pages.length - 2].options
  262. );
  263. }
  264. this.jumpPostion()
  265. } else {
  266. uni.switchTab({
  267. url: `/pages/index/index`
  268. });
  269. }
  270. },
  271. /**
  272. * 跳转
  273. * @param {*} userInfo
  274. */
  275. jumpPostion() {
  276. const last_page = uni.getStorageSync('last_page') || '',
  277. switchTabList = ['pages/index/index', 'pages/mycode/mycode', 'pages/mine/mine']
  278. if (last_page && switchTabList.indexOf(last_page) < 0) {
  279. const last_page_options = uni.getStorageSync('last_page_options') || '';
  280. const str = JSON.stringify(last_page_options)
  281. .replaceAll('{', '')
  282. .replaceAll('}', '')
  283. .replaceAll('"', '')
  284. .replaceAll(':', '=')
  285. .replaceAll(',', '&');
  286. // 清空其他路由,直接跳转最后登录的页面
  287. uni.navigateTo({
  288. url: `/${last_page}?${str}`
  289. });
  290. return;
  291. } else {
  292. uni.switchTab({
  293. url: `/${last_page}`
  294. });
  295. }
  296. },
  297. /**
  298. * 获取已经提交的数据
  299. */
  300. getVeteEducData() {
  301. this.$u.api.getVeteEducData().then(res => {
  302. if (res.code == 200) {
  303. const data = res.data
  304. for (let key in data.veteEduc) {
  305. if (key !== 'files') {
  306. this.form[key] = data.veteEduc[key];
  307. }
  308. };
  309. if (data.veteEduc) {
  310. this.form.veteSex = data.veteEduc.veteSex === 0 ? '男' : '女';
  311. // 文化程度
  312. this.degrEducList.forEach((item, index) => {
  313. if (item.text === data.veteEduc.degrEducId) {
  314. this.degrEducIndex = [index]
  315. }
  316. })
  317. // 政治面貌
  318. this.politOutlookList.forEach((item, index) => {
  319. if (item.text === data.veteEduc.politOutlookId) {
  320. this.politOutlookIndex = [index]
  321. }
  322. })
  323. // 户籍类型
  324. this.houseTypeList.forEach((item, index) => {
  325. if (item.text === data.veteEduc.houseTypeId) {
  326. this.houseTypeIndex = [index]
  327. }
  328. })
  329. // 户籍区域
  330. if (data.veteEduc.provinceName && data.veteEduc.cityName && data.veteEduc.areaName) {
  331. this.form.veteHousehArea = data.veteEduc.provinceName + '-' + data.veteEduc
  332. .cityName + '-' + data.veteEduc.areaName;
  333. }
  334. // 薪资范围
  335. this.form.salaryRange = data.veteEduc.salaryRange
  336. this.salaryRangeList.forEach((item, index) => {
  337. if (Number(item.value) === Number(data.veteEduc.salaryRange)) {
  338. this.salaryRangeIndex = [index]
  339. this.form.salaryRangeName = item.label
  340. }
  341. })
  342. }
  343. this.form.files = data.files;
  344. }
  345. });
  346. },
  347. /**
  348. * 获取文化程度类别
  349. */
  350. getVeteDegrEduc() {
  351. this.$u.api.getDictdataUrl({
  352. key: 'degr_educ'
  353. }).then(res => {
  354. if (res.code == 200) {
  355. this.degrEducList = res.data.map(item => {
  356. return {
  357. ...item,
  358. value: item.text
  359. }
  360. });
  361. }
  362. });
  363. },
  364. /**
  365. * 文化程度下拉变化
  366. */
  367. degrEducChange(item) {
  368. this.form.degrEduc = item[0].label
  369. this.form.degrEducId = item[0].value
  370. },
  371. /**
  372. * 获取政治面貌类别
  373. */
  374. getVetePolitOutlook() {
  375. this.$u.api.getDictdataUrl({
  376. key: 'polit_outlook'
  377. }).then(res => {
  378. if (res.code == 200) {
  379. this.politOutlookList = res.data.map(item => {
  380. return {
  381. ...item,
  382. value: item.text
  383. }
  384. });
  385. }
  386. });
  387. },
  388. /**
  389. * 政治面貌下拉改变
  390. */
  391. politOutlookChange(item) {
  392. this.form.politOutlook = item[0].label
  393. this.form.politOutlookId = item[0].value
  394. },
  395. /**
  396. * 户籍地
  397. */
  398. regionConfirm(e) {
  399. this.form.veteHousehRegi = `${e.province.label}-${e.city.label}`
  400. },
  401. /**
  402. * 户籍地点击
  403. */
  404. regionClick() {
  405. this.regionShow = true
  406. },
  407. /**
  408. * 户籍区域
  409. */
  410. areaConfirm(e) {
  411. this.form.veteHousehArea = `${e.province.label}-${e.city.label}-${e.area.label}`
  412. this.form.provinceId = e.province.value
  413. this.form.provinceName = e.province.label
  414. this.form.cityId = e.city.value
  415. this.form.cityName = e.city.label
  416. this.form.areaId = e.area.value
  417. this.form.areaName = e.area.label
  418. },
  419. /**
  420. * 获取户籍类别
  421. */
  422. getVeteHouseType() {
  423. this.$u.api.getDictdataUrl({
  424. key: 'house_type'
  425. }).then(res => {
  426. if (res.code === 200) {
  427. this.houseTypeList = res.data.map(item => {
  428. return {
  429. ...item,
  430. value: item.text
  431. }
  432. });
  433. }
  434. });
  435. },
  436. /**
  437. * 户籍类别单选触发
  438. */
  439. houseTypeChange(val) {
  440. this.houseTypeList.forEach(item => {
  441. if (item.value === val) {
  442. this.form.houseType = item.label
  443. }
  444. })
  445. },
  446. /**
  447. * 获取薪资范围
  448. */
  449. getSalaryRange() {
  450. this.$u.api.getDictdataUrl({
  451. key: 'salary_range'
  452. }).then(res => {
  453. if (res.code === 200) {
  454. this.salaryRangeList = res.data.map(item => {
  455. return {
  456. ...item,
  457. value: item.text
  458. }
  459. });
  460. }
  461. });
  462. },
  463. /**
  464. * 薪资范围
  465. * @param {Object} e
  466. */
  467. salaryRangeChange(e) {
  468. this.form.salaryRangeName = e[0].label
  469. this.form.salaryRange = e[0].value
  470. },
  471. /**
  472. * 就业状态
  473. */
  474. getEmploymentStatus() {
  475. this.$u.api.getDictdataUrl({
  476. key: 'member_job_status'
  477. }).then(res => {
  478. if (res.code === 200) {
  479. this.employmentStatusList = res.data.map(item => {
  480. return {
  481. ...item,
  482. value: item.text
  483. }
  484. });
  485. }
  486. });
  487. },
  488. /**
  489. * @param { String } val
  490. */
  491. idNumberChange(val) {
  492. const reg =
  493. /^\d{6}((?:19|20)((?:\d{2}(?:0[13578]|1[02])(?:0[1-9]|[12]\d|3[01]))|(?:\d{2}(?:0[13456789]|1[012])(?:0[1-9]|[12]\d|30))|(?:\d{2}02(?:0[1-9]|1\d|2[0-8]))|(?:(?:0[48]|[2468][048]|[13579][26])0229)))\d{2}(\d)[xX\d]$/
  494. if (!reg.test(val)) {
  495. return
  496. }
  497. // 根据身份证得出性别
  498. this.form.veteSex = (parseInt(val.substr(16, 1)) % 2 === 1 ? '男' : '女');
  499. // 设置出生日期
  500. this.form.veteDateBirth = val.substring(6, 10) + "-" + val.substring(10, 12) + "-" + val.substring(12,
  501. 14) + ' 00:00:00';
  502. // 根据身份证号获取基本信息
  503. this.$u.api.getIdInfo({
  504. id: this.form.veteIdCard
  505. }).then(res => {
  506. if (res.code === 200) {
  507. if (res.data) {
  508. this.form.nation = res.data.nation;
  509. this.form.veteName = res.data.veteName;
  510. this.form.vetePhone = res.data.vetePhone;
  511. this.form.veteResiAddress = res.data.veteResiAddress;
  512. }
  513. } else {
  514. uni.showToast({
  515. icon: 'none',
  516. title: res.msg
  517. })
  518. }
  519. })
  520. },
  521. /**
  522. * 图片上传成功
  523. */
  524. uploadSuccess(e) {
  525. this.form.files = []
  526. this.form.files.push({
  527. filesType: 6,
  528. filesUrl: e.data.url
  529. })
  530. },
  531. /**
  532. * 图片移除
  533. * @param {Object} index
  534. */
  535. uploadRemove(index) {
  536. this.form.files.splice(index, 1)
  537. },
  538. /**
  539. * 拍照
  540. */
  541. photograph() {
  542. uni.chooseImage({
  543. count: 1,
  544. sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  545. sourceType: ['camera'], //从相册选择
  546. success: (res) => {
  547. const tempFilePaths = res.tempFilePaths;
  548. uni.uploadFile({
  549. url: this.config.uploadUrl, // 服务器地址
  550. fileType: "image", // ZFB必填,不然报错
  551. filePath: tempFilePaths[0], // 这个就是我们上面拍照返回或者先中照片返回的数组
  552. header: {
  553. Authorization: `Bearer ${vuex_token}`
  554. },
  555. name: 'imgFile',
  556. success: (uploadFileRes) => {
  557. const file = JSON.parse(uploadFileRes.data)
  558. this.form.files = []
  559. this.form.files.push({
  560. filesType: 6,
  561. filesUrl: file.data.url
  562. })
  563. }
  564. });
  565. }
  566. })
  567. },
  568. /**
  569. * 清空图片文件
  570. */
  571. clearFile() {
  572. uni.showModal({
  573. title: '提示',
  574. content: '您确定要删除此项吗?',
  575. success: async (res) => {
  576. if (res.confirm) {
  577. this.form.files = []
  578. }
  579. }
  580. });
  581. },
  582. submit() {
  583. this.$refs.uForm.validate(valid => {
  584. if (valid) {
  585. if (this.form.files.length < 1) {
  586. uni.showToast({
  587. title: '近期1寸免冠照片',
  588. icon: 'none',
  589. duration: 2000
  590. });
  591. } else {
  592. let params = {
  593. veteEduc: {}
  594. };
  595. params.files = this.form.files
  596. for (let key in this.form) {
  597. if (key !== 'files') {
  598. params.veteEduc[key] = this.form[key];
  599. }
  600. };
  601. params.veteEduc.veteSex = params.veteEduc.veteSex === '男' ? 0 : 1;
  602. this.$u.api.veteEduc(params).then(res => {
  603. if (res.code === 200) {
  604. uni.showToast({
  605. title: '提交成功,等待审核!',
  606. duration: 2000,
  607. success: () => {
  608. this.$u.route(
  609. '/pages/applyEducationCode/applyEducationSuccess'
  610. )
  611. }
  612. });
  613. } else {
  614. uni.showToast({
  615. title: res.msg,
  616. icon: 'none',
  617. duration: 2000
  618. });
  619. }
  620. })
  621. }
  622. }
  623. });
  624. }
  625. }
  626. }
  627. </script>
  628. <style lang="scss" scoped>
  629. @import './applyEducationCode.scss';
  630. </style>