gerenZiliao.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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"><text class="form-label-require">*</text>身份证号</view>
  16. <uni-easyinput v-model="formData.idCard" placeholder="请输入身份证号" maxlength="18" />
  17. </view>
  18. <view class="form-label-input">
  19. <view class="phone-form-label"><text class="form-label-require">*</text>生日</view>
  20. <uni-datetime-picker type="line" v-model="formData.birthday">
  21. <view class="form-radio-select">
  22. {{formData.birthday}}
  23. <icon></icon>
  24. </view>
  25. </uni-datetime-picker>
  26. </view>
  27. <view class="form-label-input">
  28. <view class="phone-form-label"><text class="form-label-require">*</text>籍贯</view>
  29. <picker mode="multiSelector" :range="multiArray" :range-key="'label'" :value="multiIndex"
  30. @columnchange="bindMultiPickerColumnChange" @change="onPickerConfirm">
  31. <view class="picker">
  32. {{ formData.jiguanShengName}}-{{formData.jiguanShiName}} 箭头
  33. </view>
  34. </picker>
  35. </view>
  36. <view class="form-label-input">
  37. <view class="phone-form-label"><text class="form-label-require">*</text>身份证地址</view>
  38. <uni-easyinput v-model="formData.hujiDizhi" placeholder="请输入身份证地址" />
  39. </view>
  40. <view class="form-label-input">
  41. <view class="phone-form-label"><text class="form-label-require">*</text>民族</view>
  42. <picker :range="minzuList" mode='selector' :value="formData.minzuIndex" range-key="name"
  43. @change="minzuChange" @cancel="minzuCancel">
  44. <view class="form-radio-select">
  45. <view>{{ formData.minzu.name }}</view>
  46. <icon></icon>
  47. </view>
  48. </picker>
  49. </view>
  50. <view class="form-label-radio">
  51. <view class="phone-form-label"><text class="form-label-require">*</text>性别</view>
  52. <view class="form-radio-group">
  53. <view class="form-radio-item" :class="{genderActive: formData.gender===1}" @click="genderSelect(1)">
  54. 男</view>
  55. <view class="form-radio-item" :class="{genderActive: formData.gender===2}" @click="genderSelect(2)">
  56. 女</view>
  57. </view>
  58. </view>
  59. <view class="form-label-radio form-top-margin flex-start-row">
  60. <view class="phone-form-label"><text class="form-label-require">*</text>学历</view>
  61. <dataChecked :list="xueliList" mode="single" :showAdd="false" @change="selectChangeXueliList" />
  62. </view>
  63. <view class="form-label-radio flex-start-row">
  64. <view class="phone-form-label"><text></text>婚姻 </view>
  65. <dataChecked :list="hunyinList" mode="single" :showAdd="false" @change="selectChangeHunyinList" />
  66. </view>
  67. <view class="form-label-input form-top-margin flex-start-row">
  68. <view class="phone-form-label"><text></text>通讯地址</view>
  69. <textarea v-model="formData.juzhuDizhi" placeholder="请输入通讯地址" class="form-textarea-box" />
  70. </view>
  71. <view class="form-label-select">
  72. <view class="phone-form-label"><text></text>星座</view>
  73. <picker :range="xingzuoList" mode='selector' :value="formData.xingzuoIndex" range-key="name"
  74. @change="xingzuoChange" @cancel="xingzuoCancel">
  75. <view class="form-radio-select">
  76. <view>{{ formData.xingzuo.name || '请选择星座' }}</view>
  77. <icon></icon>
  78. </view>
  79. </picker>
  80. </view>
  81. <view class="form-label-select">
  82. <view class="phone-form-label"><text></text>属相</view>
  83. <picker :range="shuxiangList" mode='selector' :value="formData.shuxiangIndex" range-key="name"
  84. @change="shuxiangChange" @cancel="shuxiangCancel">
  85. <view class="form-radio-select">
  86. <view>{{ formData.shuxiang.name || '请选择属相' }}</view>
  87. <icon></icon>
  88. </view>
  89. </picker>
  90. </view>
  91. <view class="form-label-switch">
  92. <view class="phone-form-label"> <text class="form-label-require"></text>星座属相展示到简历 </view>
  93. <view>展示
  94. <switch @change="switchXingzuoChange" :checked="formData.xingzuoFlag" color="#3fd2a1"
  95. style="transform:scale(0.7)" />
  96. </view>
  97. </view>
  98. <view class="agree-section-box form-top-margin">
  99. <checkbox-group @change="handleAgree">
  100. <label class="checkbox">
  101. <checkbox :checked="formData.agree" color="#3fd2a1" style="transform:scale(0.65)" />
  102. <text>已征得本人同意,将其个人资料信息录入平台</text>
  103. </label>
  104. </checkbox-group>
  105. <button type="default" @click="goNext" class="phone-green-btn">下一步</button>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import dataChecked from './common/dataChecked.vue';
  111. import jiazhengUpload from "./common/jiazhengUpload.vue"
  112. import {
  113. getJiazhengXueli,
  114. getJiazhengHunyin,
  115. getJiazhengMinzu,
  116. getJiazhengShuxiang,
  117. getJiazhengXingzuo,
  118. getJiazhengJiguan
  119. } from "@/api/jiazheng.js";
  120. export default {
  121. components: {
  122. dataChecked,
  123. jiazhengUpload
  124. },
  125. data() {
  126. return {
  127. formData: {
  128. userName: '',
  129. realName: '',
  130. idCard: '',
  131. icon: '',
  132. birthday: '',
  133. hometown: [],
  134. hujiDizhi: '',
  135. gender: '',
  136. juzhuDizhi: '',
  137. minzu: {},
  138. shuxiang: {},
  139. xingzuo: {},
  140. hunyin: {},
  141. xueli: {},
  142. jiguanObj: {},
  143. jiguanShengId:'',
  144. jiguanShiId:'',
  145. jiguanShiName:'',
  146. jiguanShengName:'',
  147. agree: false,
  148. xingzuoIndex: 0,
  149. minzuIndex: 0,
  150. shuxiangIndex: 0,
  151. xingzuoFlag: false
  152. },
  153. xueliList: [],
  154. hunyinList: [],
  155. shuxiangList: [],
  156. xingzuoList: [],
  157. minzuList: [],
  158. // areaTree: [],
  159. multiArray: [
  160. [],
  161. []
  162. ], // 初始化两列数据
  163. multiIndex: [0, 0], // 初始化选中索引
  164. allData: [], // 存储后端返回的完整数据
  165. }
  166. },
  167. created() {
  168. this.getXueli()
  169. this.getHunyin()
  170. this.getMinzu()
  171. this.getXingzuo()
  172. this.getShuxiang()
  173. this.getJiguan()
  174. },
  175. methods: {
  176. getJiguan() {
  177. getJiazhengJiguan({}).then(res => {
  178. // this.areaTree = res.data
  179. // this.pickerData = this.formatData(res.data);
  180. this.allData = res.data;
  181. const provinces = this.allData.map(province => ({
  182. label: province.lable,
  183. value: province.id,
  184. children: province.children,
  185. }));
  186. const cities = this.allData[0].children.map(city => ({
  187. label: city.lable,
  188. value: city.id,
  189. }));
  190. // 回显已选中的城市(假设已选中的城市 id 是 1301)
  191. //this.setSelectedCity(1301);
  192. this.multiArray = [provinces, cities];
  193. //console.log('this.pickerData', this.pickerData);
  194. }).catch(error => {
  195. console.error('获取技能类型失败:', error);
  196. });
  197. },
  198. bindMultiPickerColumnChange(e) {
  199. const {
  200. column,
  201. value
  202. } = e.detail;
  203. // 更新 multiIndex
  204. this.multiIndex[column] = value;
  205. // 如果是第一列(省份)发生变化,更新第二列(城市)
  206. if (column === 0) {
  207. const selectedProvince = this.multiArray[0][value];
  208. const cities = selectedProvince.children.map(city => ({
  209. label: city.lable,
  210. value: city.id,
  211. }));
  212. // 更新 multiArray 和 multiIndex
  213. this.multiArray[1] = cities;
  214. this.multiIndex[1] = 0; // 重置城市列为第一个选项
  215. }
  216. // 强制更新视图
  217. //this.$forceUpdate();
  218. },
  219. // 确认选择时获取完整数据
  220. onPickerConfirm() {
  221. const [provinceIndex, cityIndex] = this.multiIndex;
  222. const selectedProvince = this.multiArray[0][provinceIndex];
  223. const selectedCity = this.multiArray[1][cityIndex];
  224. this.formData.jiguanShengId = selectedProvince.value
  225. this.formData.jiguanShiId = selectedCity.value
  226. this.formData.jiguanShiName = selectedCity.label
  227. this.formData.jiguanShengName = selectedProvince.label
  228. this.formData.jiguanObj.jiguanShengId = selectedProvince.value
  229. this.formData.jiguanObj.jiguanShiId =selectedCity.value
  230. console.log("选中的省份完整数据:", selectedProvince);
  231. console.log("选中的城市完整数据:", selectedCity);
  232. },
  233. setSelectedCity(cityId) {
  234. for (let i = 0; i < this.allData.length; i++) {
  235. const province = this.allData[i];
  236. for (let j = 0; j < province.children.length; j++) {
  237. const city = province.children[j];
  238. if (city.id === cityId) {
  239. // 设置选中的省份和城市索引
  240. this.multiIndex = [i, j];
  241. // 更新 multiArray 的第二列(城市)
  242. const cities = province.children.map(city => ({
  243. label: city.lable,
  244. value: city.id,
  245. }));
  246. this.multiArray[1] = cities;
  247. // 强制更新视图
  248. this.$forceUpdate();
  249. return;
  250. }
  251. }
  252. }
  253. },
  254. checkAllFields() {
  255. const requiredFields = [{
  256. key: 'userName',
  257. name: '手机号'
  258. },
  259. {
  260. key: 'realName',
  261. name: '姓名'
  262. },
  263. {
  264. key: 'idCard',
  265. name: '身份证号'
  266. },
  267. {
  268. key: 'birthday',
  269. name: '生日'
  270. },
  271. // {
  272. // key: 'hometown',
  273. // name: '家乡',
  274. // type: 'array'
  275. // },
  276. // {
  277. // key: 'hujiDizhi',
  278. // name: '身份证地址'
  279. // },
  280. {
  281. key: 'gender',
  282. name: '性别'
  283. },
  284. // {
  285. // key: 'juzhuDizhi',
  286. // name: '通讯地址'
  287. // },
  288. {
  289. key: 'minzu',
  290. name: '民族',
  291. type: 'object'
  292. },
  293. {
  294. key: 'jiguanObj',
  295. name: '籍贯',
  296. type: 'object'
  297. },
  298. {
  299. key: 'xueli',
  300. name: '学历',
  301. type: 'object'
  302. },
  303. // {
  304. // key: 'shuxiang',
  305. // name: '属相',
  306. // type: 'object'
  307. // },
  308. // {
  309. // key: 'xingzuo',
  310. // name: '星座',
  311. // type: 'object'
  312. // },
  313. ]
  314. for (const field of requiredFields) {
  315. const value = this.formData[field.key]
  316. // 根据不同类型进行存在验证
  317. if (field.type === 'array' && !value?.length) {
  318. this.showAlert(field.name)
  319. return false
  320. }
  321. if (field.type === 'object' && !Object.keys(value).length) {
  322. this.showAlert(field.name)
  323. return false
  324. }
  325. if (field.type === 'boolean' && value !== true) {
  326. this.showAlert(field.name)
  327. return false
  328. }
  329. if (!field.type && !value?.toString().trim()) {
  330. this.showAlert(field.name)
  331. return false
  332. }
  333. }
  334. return true
  335. },
  336. showAlert(fieldName) {
  337. uni.showToast({
  338. title: `${fieldName}不能为空`,
  339. icon: 'none',
  340. duration: 2000
  341. })
  342. },
  343. getXueli() {
  344. getJiazhengXueli({}).then(res => {
  345. this.xueliList = res.data
  346. // console.log('xueliList', this.xueliList);
  347. }).catch(error => {
  348. console.error('获取技能类型失败:', error);
  349. });
  350. },
  351. getXingzuo() {
  352. getJiazhengXingzuo({}).then(res => {
  353. this.xingzuoList = res.data
  354. // console.log('xingzuoList', this.xingzuoList);
  355. }).catch(error => {
  356. console.error('获取技能类型失败:', error);
  357. });
  358. },
  359. getShuxiang() {
  360. getJiazhengShuxiang({}).then(res => {
  361. this.shuxiangList = res.data
  362. // console.log('shuxiangList', this.shuxiangList);
  363. }).catch(error => {
  364. console.error('获取技能类型失败:', error);
  365. });
  366. },
  367. getHunyin() {
  368. getJiazhengHunyin({}).then(res => {
  369. this.hunyinList = res.data
  370. // console.log('hunyinList', this.hunyinList);
  371. }).catch(error => {
  372. console.error('获取技能类型失败:', error);
  373. });
  374. },
  375. getMinzu() {
  376. getJiazhengMinzu({}).then(res => {
  377. this.minzuList = res.data
  378. // console.log('minzuList', this.minzuList);
  379. }).catch(error => {
  380. console.error('获取技能类型失败:', error);
  381. });
  382. },
  383. getFileUrl(data) {
  384. this.formData.icon = data
  385. console.log('data', data);
  386. },
  387. minzuChange(e) {
  388. const index = e.detail.value
  389. this.formData.minzu = this.minzuList[index]
  390. //console.log('this.formData.minzu', this.formData.minzu);
  391. },
  392. minzuCancel() {
  393. this.formData.minzuIndex = 0
  394. },
  395. xingzuoChange(e) {
  396. const index = e.detail.value
  397. this.formData.xingzuo = this.xingzuoList[index]
  398. // console.log('this.formData.xingzuo', this.formData.xingzuo);
  399. },
  400. xingzuoCancel() {
  401. this.formData.xingzuoIndex = 0
  402. },
  403. shuxiangChange(e) {
  404. const index = e.detail.value
  405. this.formData.shuxiang = this.shuxiangList[index]
  406. //console.log('this.formData.shuxiang', this.formData.shuxiang);
  407. },
  408. shuxiangCancel() {
  409. this.formData.shuxiangIndex = 0
  410. },
  411. selectChangeXueliList(data) {
  412. this.formData.xueli = data
  413. },
  414. genderSelect(data) {
  415. this.formData.gender = data
  416. },
  417. selectChangeHunyinList(data) {
  418. this.formData.hunyin = data
  419. },
  420. switchXingzuoChange(e) {
  421. this.formData.xingzuoFlag = e.detail.value
  422. },
  423. goNext() {
  424. console.log('formData', this.formData);
  425. if (!this.checkAllFields()) {
  426. return false
  427. }
  428. if(!this.formData.agree){
  429. uni.showToast({
  430. title: "请勾选本人同意!",
  431. icon: 'none',
  432. duration: 2000
  433. })
  434. return false
  435. }
  436. this.$emit('goNext',this.formData,0);
  437. },
  438. handleAgree(e) {
  439. this.formData.agree = e.detail.value.length > 0
  440. },
  441. }
  442. }
  443. </script>