gerenZiliao.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. this.initRequests()
  191. },
  192. methods: {
  193. async initRequests() {
  194. await Promise.all([
  195. this.getXueli(),
  196. this.getHunyin(),
  197. this.getMinzu(),
  198. this.getXingzuo(),
  199. this.getShuxiang(),
  200. this.getJiguan(),
  201. ]);
  202. if (this.status == 'edit') {
  203. this.$emit('finishDom','gerenZiliao');
  204. }
  205. },
  206. editinfo(data) {
  207. this.$nextTick(() => {
  208. this.formData.userName = data.userName
  209. this.formData.realName = data.realName
  210. this.formData.idcard = data.idcard
  211. this.formData.idtype = data.idtype
  212. this.formData.jiguanObj.jiguanShengId = data.jiguanShengId
  213. this.formData.jiguanShengName = data.jiguanShengName
  214. this.formData.jiguanObj.jiguanShiId = data.jiguanShiId
  215. this.formData.jiguanShiName = data.jiguanShiName
  216. this.formData.juzhuDizhi = data.juzhuDizhi
  217. this.formData.birthday = data.birthday
  218. this.formData.minzu = this.dataForId(this.minzuList, data.minzu)||''
  219. this.formData.gender = data.gender
  220. this.formData.xueli = this.dataForId(this.xueliList, data.xueli)||''
  221. this.formData.hunyin = this.dataForId(this.hunyinList, data.hunyin)||''
  222. this.formData.hujiDizhi = data.hujiDizhi
  223. this.formData.juzhuDizhi = data.juzhuDizhi
  224. this.formData.xingzuo = this.dataForId(this.xingzuoList, data.xingzuo) || ''
  225. this.formData.shuxiang = this.dataForId(this.shuxiangList, data.xingzuo) || ''
  226. this.formData.xingzuoFlag = data.xingzuoFlag
  227. })
  228. },
  229. dataForId(list, id) {
  230. return list.find(item => item.id == id);
  231. },
  232. idCardChange(data) {
  233. this.formData.idtype = this.formData.idtype == 1 ? 2 : 1;
  234. },
  235. getJiguan() {
  236. getJiazhengJiguan({}).then(res => {
  237. // this.areaTree = res.data
  238. // this.pickerData = this.formatData(res.data);
  239. this.allData = res.data;
  240. const provinces = this.allData.map(province => ({
  241. label: province.lable,
  242. value: province.id,
  243. children: province.children,
  244. }));
  245. const cities = this.allData[0].children.map(city => ({
  246. label: city.lable,
  247. value: city.id,
  248. }));
  249. // 回显已选中的城市(假设已选中的城市 id 是 1301)
  250. //this.setSelectedCity(1301);
  251. this.multiArray = [provinces, cities];
  252. //console.log('this.pickerData', this.pickerData);
  253. }).catch(error => {
  254. console.error('获取技能类型失败:', error);
  255. });
  256. },
  257. bindMultiPickerColumnChange(e) {
  258. const {
  259. column,
  260. value
  261. } = e.detail;
  262. // 更新 multiIndex
  263. this.multiIndex[column] = value;
  264. // 如果是第一列(省份)发生变化,更新第二列(城市)
  265. if (column === 0) {
  266. const selectedProvince = this.multiArray[0][value];
  267. const cities = selectedProvince.children.map(city => ({
  268. label: city.lable,
  269. value: city.id,
  270. }));
  271. // 更新 multiArray 和 multiIndex
  272. this.multiArray[1] = cities;
  273. this.multiIndex[1] = 0; // 重置城市列为第一个选项
  274. }
  275. // 强制更新视图
  276. //this.$forceUpdate();
  277. },
  278. // 确认选择时获取完整数据
  279. onPickerConfirm() {
  280. const [provinceIndex, cityIndex] = this.multiIndex;
  281. const selectedProvince = this.multiArray[0][provinceIndex];
  282. const selectedCity = this.multiArray[1][cityIndex];
  283. this.formData.jiguanShengId = selectedProvince.value
  284. this.formData.jiguanShiId = selectedCity.value
  285. this.formData.jiguanShiName = selectedCity.label
  286. this.formData.jiguanShengName = selectedProvince.label
  287. this.formData.jiguanObj.jiguanShengId = selectedProvince.value
  288. this.formData.jiguanObj.jiguanShiId = selectedCity.value
  289. console.log("选中的省份完整数据:", selectedProvince);
  290. console.log("选中的城市完整数据:", selectedCity);
  291. },
  292. setSelectedCity(cityId) {
  293. for (let i = 0; i < this.allData.length; i++) {
  294. const province = this.allData[i];
  295. for (let j = 0; j < province.children.length; j++) {
  296. const city = province.children[j];
  297. if (city.id === cityId) {
  298. // 设置选中的省份和城市索引
  299. this.multiIndex = [i, j];
  300. // 更新 multiArray 的第二列(城市)
  301. const cities = province.children.map(city => ({
  302. label: city.lable,
  303. value: city.id,
  304. }));
  305. this.multiArray[1] = cities;
  306. // 强制更新视图
  307. this.$forceUpdate();
  308. return;
  309. }
  310. }
  311. }
  312. },
  313. checkAllFields() {
  314. const requiredFields = [{
  315. key: 'userName',
  316. name: '手机号'
  317. },
  318. {
  319. key: 'realName',
  320. name: '姓名'
  321. },
  322. {
  323. key: 'idcard',
  324. name: '身份证号'
  325. },
  326. {
  327. key: 'birthday',
  328. name: '生日'
  329. },
  330. // {
  331. // key: 'hometown',
  332. // name: '家乡',
  333. // type: 'array'
  334. // },
  335. // {
  336. // key: 'hujiDizhi',
  337. // name: '身份证地址'
  338. // },
  339. {
  340. key: 'gender',
  341. name: '性别'
  342. },
  343. // {
  344. // key: 'juzhuDizhi',
  345. // name: '通讯地址'
  346. // },
  347. {
  348. key: 'minzu',
  349. name: '民族',
  350. type: 'object'
  351. },
  352. {
  353. key: 'jiguanObj',
  354. name: '籍贯',
  355. type: 'object'
  356. },
  357. {
  358. key: 'xueli',
  359. name: '学历',
  360. type: 'object'
  361. },
  362. // {
  363. // key: 'shuxiang',
  364. // name: '属相',
  365. // type: 'object'
  366. // },
  367. // {
  368. // key: 'xingzuo',
  369. // name: '星座',
  370. // type: 'object'
  371. // },
  372. ]
  373. for (const field of requiredFields) {
  374. const value = this.formData[field.key]
  375. // 根据不同类型进行存在验证
  376. if (field.type === 'array' && !value?.length) {
  377. this.showAlert(field.name)
  378. return false
  379. }
  380. if (field.type === 'object' && !Object.keys(value).length) {
  381. this.showAlert(field.name)
  382. return false
  383. }
  384. if (field.type === 'boolean' && value !== true) {
  385. this.showAlert(field.name)
  386. return false
  387. }
  388. if (!field.type && !value?.toString().trim()) {
  389. this.showAlert(field.name)
  390. return false
  391. }
  392. }
  393. return true
  394. },
  395. showAlert(fieldName) {
  396. uni.showToast({
  397. title: `${fieldName}不能为空`,
  398. icon: 'none',
  399. duration: 2000
  400. })
  401. },
  402. getXueli() {
  403. getJiazhengXueli({}).then(res => {
  404. this.xueliList = res.data
  405. // console.log('xueliList', this.xueliList);
  406. }).catch(error => {
  407. console.error('获取技能类型失败:', error);
  408. });
  409. },
  410. getXingzuo() {
  411. getJiazhengXingzuo({}).then(res => {
  412. this.xingzuoList = res.data
  413. // console.log('xingzuoList', this.xingzuoList);
  414. }).catch(error => {
  415. console.error('获取技能类型失败:', error);
  416. });
  417. },
  418. getShuxiang() {
  419. getJiazhengShuxiang({}).then(res => {
  420. this.shuxiangList = res.data
  421. // console.log('shuxiangList', this.shuxiangList);
  422. }).catch(error => {
  423. console.error('获取技能类型失败:', error);
  424. });
  425. },
  426. getHunyin() {
  427. getJiazhengHunyin({}).then(res => {
  428. this.hunyinList = res.data
  429. // console.log('hunyinList', this.hunyinList);
  430. }).catch(error => {
  431. console.error('获取技能类型失败:', error);
  432. });
  433. },
  434. getMinzu() {
  435. getJiazhengMinzu({}).then(res => {
  436. this.minzuList = res.data
  437. // console.log('minzuList', this.minzuList);
  438. }).catch(error => {
  439. console.error('获取技能类型失败:', error);
  440. });
  441. },
  442. getFileUrl(data) {
  443. this.formData.shenfenzhengUrl = data
  444. console.log('data', data);
  445. jiazhengIdcard({url:this.formData.shenfenzhengUrl}).then(res=>{
  446. console.log('res',res);
  447. if(res.code ==0){
  448. this.formData.realName = res.data.name
  449. this.formData.gender = res.data.sex
  450. this.formData.minzu = res.data.ethnicity
  451. this.formData.realName = res.data.name
  452. this.formData.realName = res.data.name
  453. this.formData.realName = res.data.name
  454. this.formData.realName = res.data.name
  455. }
  456. })
  457. },
  458. minzuChange(e) {
  459. const index = e.detail.value
  460. this.formData.minzu = this.minzuList[index]
  461. //console.log('this.formData.minzu', this.formData.minzu);
  462. },
  463. minzuCancel() {
  464. this.formData.minzuIndex = 0
  465. },
  466. xingzuoChange(e) {
  467. const index = e.detail.value
  468. this.formData.xingzuo = this.xingzuoList[index]
  469. // console.log('this.formData.xingzuo', this.formData.xingzuo);
  470. },
  471. xingzuoCancel() {
  472. this.formData.xingzuoIndex = 0
  473. },
  474. shuxiangChange(e) {
  475. const index = e.detail.value
  476. this.formData.shuxiang = this.shuxiangList[index]
  477. //console.log('this.formData.shuxiang', this.formData.shuxiang);
  478. },
  479. shuxiangCancel() {
  480. this.formData.shuxiangIndex = 0
  481. },
  482. selectChangeXueliList(data) {
  483. this.formData.xueli = data[0]
  484. },
  485. genderSelect(data) {
  486. this.formData.gender = data
  487. },
  488. selectChangeHunyinList(data) {
  489. console.log('data',data[0]);
  490. this.formData.hunyin = data[0]
  491. },
  492. switchXingzuoChange(e) {
  493. this.formData.xingzuoFlag = e.detail.value
  494. },
  495. goNext() {
  496. console.log('formData', this.formData);
  497. if (!this.checkAllFields()) {
  498. return false
  499. }
  500. if (!this.formData.agree) {
  501. uni.showToast({
  502. title: "请勾选本人同意!",
  503. icon: 'none',
  504. duration: 2000
  505. })
  506. return false
  507. }
  508. this.$emit('goNext', this.formData, 0);
  509. },
  510. editSave() {
  511. console.log('formData', this.formData);
  512. if (!this.checkAllFields()) {
  513. return false
  514. }
  515. if (!this.formData.agree) {
  516. uni.showToast({
  517. title: "请勾选本人同意!",
  518. icon: 'none',
  519. duration: 2000
  520. })
  521. return false
  522. }
  523. this.$emit('editSave', this.formData);
  524. },
  525. handleAgree(e) {
  526. this.formData.agree = e.detail.value.length > 0
  527. },
  528. }
  529. }
  530. </script>