gerenZiliao.vue 13 KB

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