gerenZiliao.vue 16 KB

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