gerenZiliao.vue 18 KB

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