gerenZiliao.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <view class="jz-content-box">
  3. <view class="upload-img-box">
  4. <jiazhengUpload @getFileUrl="getFileUrl" changjingType="shenfenzheng"></jiazhengUpload>
  5. </view>
  6. <view class="form-label-input">
  7. <view class="phone-form-label"><text class="form-label-require">*</text>手机号</view>
  8. <uni-easyinput type="number" v-model="formData.userName" placeholder="请输入手机号" maxlength="11" />
  9. </view>
  10. <view class="form-label-input">
  11. <view class="phone-form-label"><text class="form-label-require">*</text>姓名</view>
  12. <uni-easyinput v-model="formData.realName" placeholder="请输入姓名" />
  13. </view>
  14. <view class="form-label-input">
  15. <view class="phone-form-label">
  16. <text class="form-label-require">*</text>
  17. <text v-if="formData.idtype ==1">身份证号</text>
  18. <text v-if="formData.idtype ==2">护照号</text>
  19. <text @click="idCardChange">切换</text>
  20. </view>
  21. <uni-easyinput v-model="formData.idcard" placeholder="请输入身份证号或护照号" maxlength="18" />
  22. </view>
  23. <view class="form-label-input">
  24. <view class="phone-form-label"><text class="form-label-require">*</text>生日</view>
  25. <uni-datetime-picker type="line" v-model="formData.birthday">
  26. <view class="form-radio-select">
  27. {{formData.birthday}}
  28. <icon></icon>
  29. </view>
  30. </uni-datetime-picker>
  31. </view>
  32. <view class="form-label-input">
  33. <view class="phone-form-label"><text class="form-label-require">*</text>籍贯</view>
  34. <picker mode="multiSelector" :range="multiArray" :range-key="'label'" :value="multiIndex"
  35. @columnchange="bindMultiPickerColumnChange" @change="onPickerConfirm">
  36. <view class="picker">
  37. {{ formData.jiguanShengName}} {{formData.jiguanShiName}} 箭头
  38. </view>
  39. </picker>
  40. </view>
  41. <view class="form-label-input">
  42. <view class="phone-form-label"><text class="form-label-require">*</text>身份证地址</view>
  43. <uni-easyinput v-model="formData.hujiDizhi" placeholder="请输入身份证地址" />
  44. </view>
  45. <view class="form-label-input">
  46. <view class="phone-form-label"><text class="form-label-require">*</text>民族</view>
  47. <picker :range="minzuList" mode='selector' :value="formData.minzuIndex" range-key="name"
  48. @change="minzuChange" @cancel="minzuCancel">
  49. <view class="form-radio-select">
  50. <view>{{ formData.minzu.name }}</view>
  51. <icon></icon>
  52. </view>
  53. </picker>
  54. </view>
  55. <view class="form-label-radio">
  56. <view class="phone-form-label"><text class="form-label-require">*</text>性别</view>
  57. <view class="form-radio-group">
  58. <view class="form-radio-item" :class="{genderActive: formData.gender==1}" @click="genderSelect(1)">
  59. 男</view>
  60. <view class="form-radio-item" :class="{genderActive: formData.gender==2}" @click="genderSelect(2)">
  61. 女</view>
  62. </view>
  63. </view>
  64. <view class="form-label-radio form-top-margin flex-start-row">
  65. <view class="phone-form-label"><text class="form-label-require">*</text>学历</view>
  66. <dataChecked :list="xueliList" :selectedIds='formData.xueli.id' mode="single" :showAdd="false"
  67. @change="selectChangeXueliList" />
  68. </view>
  69. <view class="form-label-radio flex-start-row">
  70. <view class="phone-form-label"><text></text>婚姻 </view>
  71. <dataChecked :list="hunyinList" mode="single" :selectedIds='formData.hunyin.id' :showAdd="false"
  72. @change="selectChangeHunyinList" />
  73. </view>
  74. <view class="form-label-input form-top-margin flex-start-row">
  75. <view class="phone-form-label"><text></text>通讯地址</view>
  76. <textarea v-model="formData.juzhuDizhi" placeholder="请输入通讯地址" class="form-textarea-box" />
  77. </view>
  78. <view class="form-label-select">
  79. <view class="phone-form-label"><text></text>星座</view>
  80. <picker :range="xingzuoList" mode='selector' :value="formData.xingzuoIndex" range-key="name"
  81. @change="xingzuoChange" @cancel="xingzuoCancel">
  82. <view class="form-radio-select">
  83. <view>{{ formData.xingzuo.name || '请选择星座' }}</view>
  84. <icon></icon>
  85. </view>
  86. </picker>
  87. </view>
  88. <view class="form-label-select">
  89. <view class="phone-form-label"><text></text>属相</view>
  90. <picker :range="shuxiangList" mode='selector' :value="formData.shuxiangIndex" range-key="name"
  91. @change="shuxiangChange" @cancel="shuxiangCancel">
  92. <view class="form-radio-select">
  93. <view>{{ formData.shuxiang.name || '请选择属相' }}</view>
  94. <icon></icon>
  95. </view>
  96. </picker>
  97. </view>
  98. <view class="form-label-switch">
  99. <view class="phone-form-label"> <text class="form-label-require"></text>星座属相展示到简历 </view>
  100. <view>展示
  101. <switch @change="switchXingzuoChange" :checked="formData.xingzuoFlag" color="#3fd2a1"
  102. style="transform:scale(0.7)" />
  103. </view>
  104. </view>
  105. <view class="agree-section-box form-top-margin">
  106. <checkbox-group @change="handleAgree">
  107. <label class="checkbox">
  108. <checkbox :checked="formData.agree" color="#3fd2a1" style="transform:scale(0.65)" />
  109. <text>已征得本人同意,将其个人资料信息录入平台</text>
  110. </label>
  111. </checkbox-group>
  112. <button type="default" v-if="status =='add'" @click="goNext" class="phone-green-btn">下一步</button>
  113. <button type="default" v-if="status =='edit'" @click="editSave" class="phone-green-btn">保存</button>
  114. </view>
  115. </view>
  116. </template>
  117. <script>
  118. import dataChecked from './common/dataChecked.vue';
  119. import jiazhengUpload from "./common/jiazhengUpload.vue"
  120. import {
  121. getJiazhengXueli,
  122. getJiazhengHunyin,
  123. getJiazhengMinzu,
  124. getJiazhengShuxiang,
  125. getJiazhengXingzuo,
  126. getJiazhengJiguan,
  127. jiazhengIdcard
  128. } from "@/api/jiazheng.js";
  129. export default {
  130. components: {
  131. dataChecked,
  132. jiazhengUpload
  133. },
  134. props: {
  135. status: {
  136. type: String,
  137. }
  138. },
  139. data() {
  140. return {
  141. formData: {
  142. userName: '',
  143. realName: '',
  144. idcard: '',
  145. icon: '',
  146. birthday: '',
  147. hujiDizhi: '',
  148. idtype: '1',
  149. gender: '',
  150. juzhuDizhi: '',
  151. shenfenzhengUrl: '',
  152. minzu: {},
  153. shuxiang: {
  154. },
  155. xingzuo: {
  156. },
  157. hunyin: {
  158. name: '',
  159. },
  160. xueli: {
  161. },
  162. jiguanObj: {},
  163. jiguanShengId: '',
  164. jiguanShiId: '',
  165. jiguanShiName: '',
  166. jiguanShengName: '',
  167. agree: false,
  168. xingzuoIndex: 0,
  169. minzuIndex: 0,
  170. shuxiangIndex: 0,
  171. xingzuoFlag: false
  172. },
  173. selectedIds: [],
  174. ceshidata: '',
  175. xueliList: [],
  176. hunyinList: [],
  177. shuxiangList: [],
  178. xingzuoList: [],
  179. minzuList: [],
  180. // areaTree: [],
  181. multiArray: [
  182. [],
  183. []
  184. ], // 初始化两列数据
  185. multiIndex: [0, 0], // 初始化选中索引
  186. allData: [], // 存储后端返回的完整数据
  187. }
  188. },
  189. created() {
  190. uni.showLoading({
  191. title: '加载中'
  192. });
  193. this.initRequests()
  194. },
  195. methods: {
  196. async initRequests() {
  197. try {
  198. await Promise.all([
  199. this.getXueli(),
  200. this.getHunyin(),
  201. this.getMinzu(),
  202. this.getXingzuo(),
  203. this.getShuxiang(),
  204. this.getJiguan(),
  205. ]);
  206. uni.hideLoading();
  207. if (this.status == 'edit') {
  208. this.$emit('finishDom', 'gerenZiliao');
  209. }
  210. } catch (e) {
  211. uni.hideLoading();
  212. uni.showToast({
  213. title: `请求失败!`,
  214. icon: 'none',
  215. duration: 2000
  216. })
  217. }
  218. },
  219. editinfo(data) {
  220. this.$nextTick(() => {
  221. this.formData.userName = data.userName
  222. this.formData.realName = data.realName
  223. this.formData.idcard = data.idcard
  224. this.formData.idtype = data.idtype
  225. this.formData.jiguanObj.jiguanShengId = data.jiguanShengId
  226. this.formData.jiguanShengName = data.jiguanShengName
  227. this.formData.jiguanObj.jiguanShiId = data.jiguanShiId
  228. this.formData.jiguanShiName = data.jiguanShiName
  229. this.formData.juzhuDizhi = data.juzhuDizhi
  230. this.formData.birthday = data.birthday
  231. this.formData.minzu = this.dataForId(this.minzuList, data.minzu) || ''
  232. this.formData.gender = data.gender
  233. this.formData.xueli = this.dataForId(this.xueliList, data.xueli) || ''
  234. this.formData.hunyin = this.dataForId(this.hunyinList, data.hunyin) || ''
  235. this.formData.hujiDizhi = data.hujiDizhi
  236. this.formData.juzhuDizhi = data.juzhuDizhi
  237. this.formData.xingzuo = this.dataForId(this.xingzuoList, data.xingzuo) || ''
  238. this.formData.shuxiang = this.dataForId(this.shuxiangList, data.xingzuo) || ''
  239. this.formData.xingzuoFlag = data.xingzuoFlag
  240. })
  241. },
  242. dataForId(list, id) {
  243. return list.find(item => item.id == id);
  244. },
  245. idCardChange(data) {
  246. this.formData.idtype = this.formData.idtype == 1 ? 2 : 1;
  247. },
  248. getJiguan() {
  249. getJiazhengJiguan({}).then(res => {
  250. // this.areaTree = res.data
  251. // this.pickerData = this.formatData(res.data);
  252. this.allData = res.data;
  253. const provinces = this.allData.map(province => ({
  254. label: province.lable,
  255. value: province.id,
  256. children: province.children,
  257. }));
  258. const cities = this.allData[0].children.map(city => ({
  259. label: city.lable,
  260. value: city.id,
  261. }));
  262. // 回显已选中的城市(假设已选中的城市 id 是 1301)
  263. //this.setSelectedCity(1301);
  264. this.multiArray = [provinces, cities];
  265. //console.log('this.pickerData', this.pickerData);
  266. }).catch(error => {
  267. console.error('获取技能类型失败:', error);
  268. });
  269. },
  270. bindMultiPickerColumnChange(e) {
  271. const {
  272. column,
  273. value
  274. } = e.detail;
  275. // 更新 multiIndex
  276. this.multiIndex[column] = value;
  277. // 如果是第一列(省份)发生变化,更新第二列(城市)
  278. if (column === 0) {
  279. const selectedProvince = this.multiArray[0][value];
  280. const cities = selectedProvince.children.map(city => ({
  281. label: city.lable,
  282. value: city.id,
  283. }));
  284. // 更新 multiArray 和 multiIndex
  285. this.multiArray[1] = cities;
  286. this.multiIndex[1] = 0; // 重置城市列为第一个选项
  287. }
  288. // 强制更新视图
  289. //this.$forceUpdate();
  290. },
  291. // 确认选择时获取完整数据
  292. onPickerConfirm() {
  293. const [provinceIndex, cityIndex] = this.multiIndex;
  294. const selectedProvince = this.multiArray[0][provinceIndex];
  295. const selectedCity = this.multiArray[1][cityIndex];
  296. this.formData.jiguanShengId = selectedProvince.value
  297. this.formData.jiguanShiId = selectedCity.value
  298. this.formData.jiguanShiName = selectedCity.label
  299. this.formData.jiguanShengName = selectedProvince.label
  300. this.formData.jiguanObj.jiguanShengId = selectedProvince.value
  301. this.formData.jiguanObj.jiguanShiId = selectedCity.value
  302. console.log("选中的省份完整数据:", selectedProvince);
  303. console.log("选中的城市完整数据:", selectedCity);
  304. },
  305. setSelectedCity(cityId) {
  306. for (let i = 0; i < this.allData.length; i++) {
  307. const province = this.allData[i];
  308. for (let j = 0; j < province.children.length; j++) {
  309. const city = province.children[j];
  310. if (city.id === cityId) {
  311. // 设置选中的省份和城市索引
  312. this.multiIndex = [i, j];
  313. // 更新 multiArray 的第二列(城市)
  314. const cities = province.children.map(city => ({
  315. label: city.lable,
  316. value: city.id,
  317. }));
  318. this.multiArray[1] = cities;
  319. // 强制更新视图
  320. this.$forceUpdate();
  321. return;
  322. }
  323. }
  324. }
  325. },
  326. checkAllFields() {
  327. const requiredFields = [{
  328. key: 'userName',
  329. name: '手机号'
  330. },
  331. {
  332. key: 'realName',
  333. name: '姓名'
  334. },
  335. {
  336. key: 'idcard',
  337. name: '身份证号'
  338. },
  339. {
  340. key: 'birthday',
  341. name: '生日'
  342. },
  343. // {
  344. // key: 'hometown',
  345. // name: '家乡',
  346. // type: 'array'
  347. // },
  348. // {
  349. // key: 'hujiDizhi',
  350. // name: '身份证地址'
  351. // },
  352. {
  353. key: 'gender',
  354. name: '性别'
  355. },
  356. // {
  357. // key: 'juzhuDizhi',
  358. // name: '通讯地址'
  359. // },
  360. {
  361. key: 'minzu',
  362. name: '民族',
  363. type: 'object'
  364. },
  365. {
  366. key: 'jiguanObj',
  367. name: '籍贯',
  368. type: 'object'
  369. },
  370. {
  371. key: 'xueli',
  372. name: '学历',
  373. type: 'object'
  374. },
  375. // {
  376. // key: 'shuxiang',
  377. // name: '属相',
  378. // type: 'object'
  379. // },
  380. // {
  381. // key: 'xingzuo',
  382. // name: '星座',
  383. // type: 'object'
  384. // },
  385. ]
  386. for (const field of requiredFields) {
  387. const value = this.formData[field.key]
  388. // 根据不同类型进行存在验证
  389. if (field.type === 'array' && !value?.length) {
  390. this.showAlert(field.name)
  391. return false
  392. }
  393. if (field.type === 'object' && !Object.keys(value).length) {
  394. this.showAlert(field.name)
  395. return false
  396. }
  397. if (field.type === 'boolean' && value !== true) {
  398. this.showAlert(field.name)
  399. return false
  400. }
  401. if (!field.type && !value?.toString().trim()) {
  402. this.showAlert(field.name)
  403. return false
  404. }
  405. }
  406. return true
  407. },
  408. showAlert(fieldName) {
  409. uni.showToast({
  410. title: `${fieldName}不能为空`,
  411. icon: 'none',
  412. duration: 2000
  413. })
  414. },
  415. getXueli() {
  416. getJiazhengXueli({}).then(res => {
  417. this.xueliList = res.data
  418. // console.log('xueliList', this.xueliList);
  419. }).catch(error => {
  420. console.error('获取技能类型失败:', error);
  421. });
  422. },
  423. getXingzuo() {
  424. getJiazhengXingzuo({}).then(res => {
  425. this.xingzuoList = res.data
  426. // console.log('xingzuoList', this.xingzuoList);
  427. }).catch(error => {
  428. console.error('获取技能类型失败:', error);
  429. });
  430. },
  431. getShuxiang() {
  432. getJiazhengShuxiang({}).then(res => {
  433. this.shuxiangList = res.data
  434. // console.log('shuxiangList', this.shuxiangList);
  435. }).catch(error => {
  436. console.error('获取技能类型失败:', error);
  437. });
  438. },
  439. getHunyin() {
  440. getJiazhengHunyin({}).then(res => {
  441. this.hunyinList = res.data
  442. // console.log('hunyinList', this.hunyinList);
  443. }).catch(error => {
  444. console.error('获取技能类型失败:', error);
  445. });
  446. },
  447. getMinzu() {
  448. getJiazhengMinzu({}).then(res => {
  449. this.minzuList = res.data
  450. // console.log('minzuList', this.minzuList);
  451. }).catch(error => {
  452. console.error('获取技能类型失败:', error);
  453. });
  454. },
  455. getFileUrl(data) {
  456. this.formData.shenfenzhengUrl = data
  457. console.log('data', data);
  458. jiazhengIdcard({
  459. url: this.formData.shenfenzhengUrl
  460. }).then(res => {
  461. console.log('res', res);
  462. if (res.code == 0) {
  463. this.formData.realName = res.data.name
  464. this.formData.gender = res.data.genderId
  465. this.formData.minzu.name = res.data.ethnicity
  466. this.formData.minzu.id = res.data.minzuId
  467. this.formData.birthday = res.data.birthDate
  468. this.formData.hujiDizhi = res.data.address
  469. this.formData.idcard = res.data.idNumber
  470. this.formData.shuxiang.id = res.data.shuxiangId
  471. this.formData.shuxiang.name = res.data.shuxiangName
  472. this.formData.xingzuo.id = res.data.xingzuoId
  473. this.formData.xingzuo.name = res.data.xingzuoName
  474. this.formData.jiguanShengId = res.data.jiguanShengId
  475. this.formData.jiguanShiId = res.data.jiguanShiId
  476. this.formData.jiguanShengName = res.data.jiguanShengName
  477. this.formData.jiguanShiName = res.data.jiguanShiName
  478. this.formData.jiguanObj.jiguanShengId = res.data.jiguanShengId
  479. this.formData.jiguanObj.jiguanShiId = res.data.jiguanShiId
  480. }
  481. })
  482. },
  483. minzuChange(e) {
  484. const index = e.detail.value
  485. this.formData.minzu = this.minzuList[index]
  486. //console.log('this.formData.minzu', this.formData.minzu);
  487. },
  488. minzuCancel() {
  489. this.formData.minzuIndex = 0
  490. },
  491. xingzuoChange(e) {
  492. const index = e.detail.value
  493. this.formData.xingzuo = this.xingzuoList[index]
  494. // console.log('this.formData.xingzuo', this.formData.xingzuo);
  495. },
  496. xingzuoCancel() {
  497. this.formData.xingzuoIndex = 0
  498. },
  499. shuxiangChange(e) {
  500. const index = e.detail.value
  501. this.formData.shuxiang = this.shuxiangList[index]
  502. //console.log('this.formData.shuxiang', this.formData.shuxiang);
  503. },
  504. shuxiangCancel() {
  505. this.formData.shuxiangIndex = 0
  506. },
  507. selectChangeXueliList(data) {
  508. this.formData.xueli = data[0]
  509. },
  510. genderSelect(data) {
  511. this.formData.gender = data
  512. },
  513. selectChangeHunyinList(data) {
  514. console.log('data', data[0]);
  515. this.formData.hunyin = data[0]
  516. },
  517. switchXingzuoChange(e) {
  518. this.formData.xingzuoFlag = e.detail.value
  519. },
  520. goNext() {
  521. console.log('formData', this.formData);
  522. if (!this.checkAllFields()) {
  523. return false
  524. }
  525. if (!this.formData.agree) {
  526. uni.showToast({
  527. title: "请勾选本人同意!",
  528. icon: 'none',
  529. duration: 2000
  530. })
  531. return false
  532. }
  533. this.$emit('goNext', this.formData, 0);
  534. },
  535. editSave() {
  536. console.log('formData', this.formData);
  537. if (!this.checkAllFields()) {
  538. return false
  539. }
  540. if (!this.formData.agree) {
  541. uni.showToast({
  542. title: "请勾选本人同意!",
  543. icon: 'none',
  544. duration: 2000
  545. })
  546. return false
  547. }
  548. this.$emit('editSave', this.formData);
  549. },
  550. handleAgree(e) {
  551. this.formData.agree = e.detail.value.length > 0
  552. },
  553. }
  554. }
  555. </script>