gerenZiliao.vue 17 KB

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