applyEducationCode.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <!-- 退役军人职业教育码申请 -->
  2. <template>
  3. <view class="apply-code">
  4. <u-form :model="form" ref="uForm" label-width="160" label-align="left">
  5. <u-form-item label="姓名:" prop="veteName" :required="true">
  6. <u-input v-model="form.veteName" placeholder="请输入真实姓名" />
  7. </u-form-item>
  8. <u-form-item label="身份证号:" prop="veteIdCard" :required="true">
  9. <u-input v-model="form.veteIdCard" placeholder="请输入身份证号" @blur="idNumberChange" />
  10. </u-form-item>
  11. <u-form-item label="性别:" prop="veteSex" :required="true">
  12. <u-input v-model="form.veteSex" placeholder="输入身份证自动获取" disabled />
  13. </u-form-item>
  14. <u-form-item label="民族:" prop="nation" :required="true">
  15. <u-input v-model="form.nation" placeholder="请输入您的民族" />
  16. </u-form-item>
  17. <u-form-item label="联系电话:" prop="vetePhone" :required="true">
  18. <u-input v-model="form.vetePhone" placeholder="请输入您的联系电话" maxlength="11" />
  19. </u-form-item>
  20. <u-form-item label="QQ:" prop="qqNum">
  21. <u-input v-model="form.qqNum" placeholder="请输入您的QQ" />
  22. </u-form-item>
  23. <u-form-item label="微信:" prop="wxNum">
  24. <u-input v-model="form.wxNum" placeholder="请输入您的微信" />
  25. </u-form-item>
  26. <u-form-item label="文化程度:" prop="degrEduc" :required="true">
  27. <u-input v-model="form.degrEduc" placeholder="请选择您的文化程度" type="select" @click="degrEducShow = true"/>
  28. </u-form-item>
  29. <u-form-item label="政治面貌:" prop="politOutlook" :required="true">
  30. <u-input v-model="form.politOutlook" placeholder="请选择您的政治面貌" type="select" @click="politOutlookShow = true"/>
  31. </u-form-item>
  32. <u-form-item label="户籍类别:" prop="houseType" :required="true">
  33. <u-input v-model="form.houseType" placeholder="请选择您的户籍类型" type="select" @click="houseTypeShow = true"/>
  34. </u-form-item>
  35. <u-form-item label="户籍地:" prop="veteHousehRegi" :required="true">
  36. <u-input v-model="form.veteHousehRegi" placeholder="请选择您的户籍地" type="select" @click="regionShow = true"/>
  37. </u-form-item>
  38. <u-form-item label="现家庭详细地址:" label-position="top" label-width="200" label-align="left" prop="veteResiAddress" :required="true">
  39. <u-input v-model="form.veteResiAddress" placeholder="请输入您的现家庭详细地址" />
  40. </u-form-item>
  41. <u-form-item label="近期1寸免冠照片:" label-position="top" label-width="200" label-align="left" prop="national">
  42. <view class="pic">
  43. <u-upload
  44. ref="uUpload"
  45. :action="action"
  46. :auto-upload="true"
  47. :custom-btn="true"
  48. :show-upload-list="false"
  49. max-count="1"
  50. :limitType="['png', 'jpg']"
  51. @on-success="uploadSuccess"
  52. >
  53. <view class="pic-upload-box" slot="addBtn">
  54. <view class="pic-upload">
  55. <image src="../../static/img/upload-add.png" mode=""/>
  56. <view class="font">上传照片</view>
  57. </view>
  58. <view class="tips">支持jpg.png格式</view>
  59. </view>
  60. </u-upload>
  61. <view class="pic-photograph" @click="photograph">
  62. <image src="../../static/img/paizhao.png" mode=""></image>
  63. <view class="font">立即拍照</view>
  64. </view>
  65. <view class="pic-url" v-if="form.files.length > 0">
  66. <view class="icon">
  67. <u-icon name="close" color="#fff" size="16" @click="clearFile"></u-icon>
  68. </view>
  69. <image :src="form.files[0].filesUrl" mode=""/>
  70. </view>
  71. </view>
  72. </u-form-item>
  73. <u-form-item>
  74. <u-button type="primary" class="submit" @click="submit">提交简历</u-button>
  75. </u-form-item>
  76. </u-form>
  77. <!-- 文化程度下拉 -->
  78. <u-select v-model="degrEducShow" :list="degrEducList" @confirm="degrEducChange" :default-value="degrEducIndex"/>
  79. <!-- 政治面貌下拉 -->
  80. <u-select v-model="politOutlookShow" :list="politOutlookList" @confirm="politOutlookChange" :default-value="politOutlookIndex"/>
  81. <!-- 户籍地 -->
  82. <u-picker mode="region" v-model="regionShow" :default-region='["贵州省", "贵阳市", "南明区"]' @confirm="regionConfirm"/>
  83. <!-- 户籍类型下拉 -->
  84. <u-select v-model="houseTypeShow" :list="houseTypeList" @confirm="houseTypeChange" :default-value="houseTypeIndex"/>
  85. </view>
  86. </template>
  87. <script>
  88. export default {
  89. data() {
  90. return {
  91. // 上传地址
  92. action: this.config.uploadUrl,
  93. form: {
  94. veteName: '',
  95. veteIdCard: '',
  96. veteSex: '',
  97. national: '',
  98. phoneNumber: '',
  99. qqNum: '',
  100. wxNum: '',
  101. degrEduc: '',
  102. degrEducId: '',
  103. houseType: '',
  104. houseTypeId:'',
  105. politOutlook: '',
  106. politOutlookId:'',
  107. veteHousehRegi: '',
  108. veteResiAddress: '',
  109. veteDateBirth:'',
  110. veteStatus: '1',
  111. veteAttribute: '',
  112. houseType: '',
  113. houseTypeId: '',
  114. veteDateBirth: '',
  115. files: []
  116. },
  117. // 表单验证
  118. rules: {
  119. veteName: [
  120. { required: true, message: '请输入姓名', trigger: [ 'change', 'blur' ]}
  121. ],
  122. veteIdCard: [
  123. {
  124. required: true,
  125. 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)$)/,
  126. // 正则检验前先将值转为字符串
  127. transform(value) {
  128. return String(value);
  129. },
  130. message: '请正确输入身份证号',
  131. trigger: ['change', 'blur']
  132. }
  133. ],
  134. vetePhone: [
  135. {
  136. pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
  137. message: '请正确输入手机号',
  138. required: true,
  139. trigger: ['change', 'blur'],
  140. }
  141. ],
  142. veteHousehRegi:[
  143. {
  144. required: true,
  145. message: '请选择户籍',
  146. }
  147. ],
  148. veteResiAddress:[
  149. {
  150. required: true,
  151. message: '请填写详细地址',
  152. }
  153. ],
  154. nation:[
  155. {
  156. required: true,
  157. message: '请填写民族',
  158. }
  159. ],
  160. degrEduc:[
  161. {
  162. required: true,
  163. message: '请选择文化程度',
  164. }
  165. ],
  166. politOutlook:[
  167. {
  168. required: true,
  169. message: '请选择政治面貌',
  170. }
  171. ],
  172. houseType:[
  173. {
  174. required: true,
  175. message: '请选择户籍类别',
  176. }
  177. ]
  178. },
  179. // 文化程度
  180. degrEducShow: false,
  181. degrEducList: [],
  182. degrEducIndex: [],
  183. // 政治面貌
  184. politOutlookShow: false,
  185. politOutlookList: [],
  186. politOutlookIndex: [],
  187. // 户籍地
  188. regionShow: false,
  189. // 户籍类型
  190. houseTypeShow: false,
  191. houseTypeList: [],
  192. houseTypeIndex: []
  193. }
  194. },
  195. onLoad() {
  196. this.getVeteEducData();
  197. this.getVeteDegrEduc();
  198. this.getVetePolitOutlook();
  199. this.getVeteHouseType();
  200. },
  201. onReady() {
  202. this.$refs.uForm.setRules(this.rules);
  203. this.form.vetePhone = this.vuex_user.mobile;
  204. },
  205. methods: {
  206. /**
  207. * 获取已经提交的数据
  208. */
  209. getVeteEducData(){
  210. this.$u.api.getVeteEducData().then(res => {
  211. if(res.code == 200){
  212. for(let key in res.data.veteEduc) {
  213. if(key !== 'files'){
  214. this.form[key] = res.data.veteEduc[key];
  215. }
  216. };
  217. if (res.data.veteEduc) {
  218. this.form.veteSex = res.data.veteEduc.veteSex === 0 ? '男' : '女';
  219. // 文化程度
  220. this.degrEducList.forEach((item, index) => {
  221. if (item.text === res.data.veteEduc.degrEducId) {
  222. this.degrEducIndex = [index]
  223. }
  224. })
  225. // 政治面貌
  226. this.politOutlookList.forEach((item, index) => {
  227. if (item.text === res.data.veteEduc.politOutlookId) {
  228. this.politOutlookIndex = [index]
  229. }
  230. })
  231. // 户籍类型
  232. this.houseTypeList.forEach((item, index) => {
  233. if (item.text === res.data.veteEduc.houseTypeId) {
  234. this.houseTypeIndex = [index]
  235. }
  236. })
  237. }
  238. this.form.files = res.data.files;
  239. }
  240. });
  241. },
  242. /**
  243. * 获取文化程度类别
  244. */
  245. getVeteDegrEduc(){
  246. this.$u.api.getDictdataUrl({key:'degr_educ'}).then(res=>{
  247. if(res.code == 200){
  248. this.degrEducList = res.data.map(item => {
  249. return {
  250. ...item,
  251. value: item.text
  252. }
  253. });
  254. }
  255. });
  256. },
  257. /**
  258. * 文化程度下拉变化
  259. */
  260. degrEducChange(item) {
  261. this.form.degrEduc = item[0].label
  262. this.form.degrEducId = item[0].value
  263. },
  264. /**
  265. * 获取政治面貌类别
  266. */
  267. getVetePolitOutlook(){
  268. this.$u.api.getDictdataUrl({ key: 'polit_outlook' }).then(res => {
  269. if(res.code == 200){
  270. this.politOutlookList = res.data.map(item => {
  271. return {
  272. ...item,
  273. value: item.text
  274. }
  275. });
  276. }
  277. });
  278. },
  279. /**
  280. * 政治面貌下拉改变
  281. */
  282. politOutlookChange(item) {
  283. this.form.politOutlook = item[0].label
  284. this.form.politOutlookId = item[0].value
  285. },
  286. /**
  287. * 户籍地
  288. */
  289. regionConfirm(e){
  290. this.form.veteHousehRegi = `${e.province.label}-${e.city.label}-${e.area.label}`
  291. },
  292. /**
  293. * 获取户籍类别
  294. */
  295. getVeteHouseType(){
  296. this.$u.api.getDictdataUrl({ key:'house_type' }).then(res => {
  297. if(res.code === 200){
  298. this.houseTypeList = res.data.map(item => {
  299. return {
  300. ...item,
  301. value: item.text
  302. }
  303. });
  304. }
  305. });
  306. },
  307. /**
  308. * 户籍类别下拉变化
  309. */
  310. houseTypeChange(e){
  311. this.form.houseType = e[0].label;
  312. this.form.houseTypeId = e[0].value;
  313. },
  314. /**
  315. * @param { String } val
  316. */
  317. idNumberChange(val) {
  318. const reg =
  319. /^\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]$/
  320. if (!reg.test(val)) {
  321. return
  322. }
  323. // 根据身份证得出性别
  324. this.form.veteSex = (parseInt(val.substr(16, 1)) % 2 === 1 ? '男' : '女');
  325. // 设置出生日期
  326. this.form.veteDateBirth = val.substring(6, 10) + "-" + val.substring(10, 12) + "-" + val.substring(12, 14) + ' 00:00:00';
  327. // 根据身份证号获取基本信息
  328. this.$u.api.getIdInfo({ id: this.form.veteIdCard }).then(res=>{
  329. if (res.code === 200) {
  330. if (res.data) {
  331. this.form.nation = res.data.nation;
  332. this.form.veteName = res.data.veteName;
  333. this.form.vetePhone = res.data.vetePhone;
  334. this.form.veteResiAddress = res.data.veteResiAddress;
  335. }
  336. } else{
  337. uni.showToast({
  338. icon: 'none',
  339. title: res.msg
  340. })
  341. }
  342. })
  343. },
  344. /**
  345. * 图片上传成功
  346. */
  347. uploadSuccess(e) {
  348. this.form.files = []
  349. this.form.files.push({ filesType: 6, filesUrl: e.data.url})
  350. },
  351. /**
  352. * 拍照
  353. */
  354. photograph() {
  355. uni.chooseImage({
  356. count: 1,
  357. sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  358. sourceType: ['camera'], //从相册选择
  359. success: (res) => {
  360. const tempFilePaths = res.tempFilePaths;
  361. uni.uploadFile({
  362. url: this.config.uploadUrl, // 服务器地址
  363. fileType: "image",// ZFB必填,不然报错
  364. filePath: tempFilePaths[0], // 这个就是我们上面拍照返回或者先中照片返回的数组
  365. name: 'imgFile',
  366. success: (uploadFileRes) => {
  367. const file = JSON.parse(uploadFileRes.data)
  368. this.form.files = []
  369. this.form.files.push({ filesType: 6, filesUrl: file.data.url})
  370. }
  371. });
  372. }
  373. })
  374. },
  375. /**
  376. * 清空图片文件
  377. */
  378. clearFile() {
  379. uni.showModal({
  380. title: '提示',
  381. content: '您确定要删除此项吗?',
  382. success: async (res) => {
  383. if (res.confirm) {
  384. this.form.files = []
  385. }
  386. }
  387. });
  388. },
  389. submit() {
  390. this.$refs.uForm.validate(valid => {
  391. if (valid) {
  392. if (this.form.files.length < 1){
  393. uni.showToast({
  394. title: '请上传所需图片',
  395. icon:'none',
  396. duration: 2000
  397. });
  398. } else {
  399. let params = {
  400. veteEduc: {}
  401. };
  402. params.files = this.form.files
  403. for(let key in this.form) {
  404. if (key !== 'files') {
  405. params.veteEduc[key] = this.form[key];
  406. }
  407. };
  408. params.veteEduc.veteSex = params.veteEduc.veteSex === '男' ? 0 : 1;
  409. this.$u.api.veteEduc(params).then(res => {
  410. if (res.code === 200 ) {
  411. uni.showToast({
  412. title: '提交成功,等待审核!',
  413. duration: 2000,
  414. success: () => {
  415. this.$u.route('/pages/applyEducationCode/applyEducationSuccess')
  416. }
  417. });
  418. } else {
  419. uni.showToast({
  420. title: res.msg,
  421. icon:'none',
  422. duration: 2000
  423. });
  424. }
  425. })
  426. }
  427. }
  428. });
  429. }
  430. }
  431. }
  432. </script>
  433. <style lang="scss" scoped>
  434. @import './applyEducationCode.scss';
  435. </style>