gerenZiliao.vue 18 KB

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