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. {{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. {{ multiArray[0][multiIndex[0]].label }} - {{ multiArray[1][multiIndex[1]].label }}
  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. birthday: '',
  132. hometown: [],
  133. hujiDizhi: '',
  134. gender: '',
  135. juzhuDizhi: '',
  136. minzu: {},
  137. shuxiang: {},
  138. xingzuo: {},
  139. hunyin: {},
  140. xueli: {},
  141. agree: false,
  142. xingzuoIndex: 0,
  143. minzuIndex: 0,
  144. shuxiangIndex: 0,
  145. xingzuoFlag: false
  146. },
  147. xueliList: [],
  148. hunyinList: [],
  149. shuxiangList: [],
  150. xingzuoList: [],
  151. minzuList: [],
  152. // areaTree: [],
  153. multiArray: [
  154. [],
  155. []
  156. ], // 初始化两列数据
  157. multiIndex: [0, 0], // 初始化选中索引
  158. allData: [], // 存储后端返回的完整数据
  159. }
  160. },
  161. created() {
  162. this.getXueli()
  163. this.getHunyin()
  164. this.getMinzu()
  165. this.getXingzuo()
  166. this.getShuxiang()
  167. this.getJiguan()
  168. },
  169. methods: {
  170. getJiguan() {
  171. getJiazhengJiguan({}).then(res => {
  172. // this.areaTree = res.data
  173. // this.pickerData = this.formatData(res.data);
  174. this.allData = res.data;
  175. const provinces = this.allData.map(province => ({
  176. label: province.lable,
  177. value: province.id,
  178. children: province.children,
  179. }));
  180. const cities = this.allData[0].children.map(city => ({
  181. label: city.lable,
  182. value: city.id,
  183. }));
  184. // 回显已选中的城市(假设已选中的城市 id 是 1301)
  185. //this.setSelectedCity(1301);
  186. this.multiArray = [provinces, cities];
  187. //console.log('this.pickerData', this.pickerData);
  188. }).catch(error => {
  189. console.error('获取技能类型失败:', error);
  190. });
  191. },
  192. bindMultiPickerColumnChange(e) {
  193. const {
  194. column,
  195. value
  196. } = e.detail;
  197. // 更新 multiIndex
  198. this.multiIndex[column] = value;
  199. // 如果是第一列(省份)发生变化,更新第二列(城市)
  200. if (column === 0) {
  201. const selectedProvince = this.multiArray[0][value];
  202. const cities = selectedProvince.children.map(city => ({
  203. label: city.lable,
  204. value: city.id,
  205. }));
  206. // 更新 multiArray 和 multiIndex
  207. this.multiArray[1] = cities;
  208. this.multiIndex[1] = 0; // 重置城市列为第一个选项
  209. }
  210. // 强制更新视图
  211. this.$forceUpdate();
  212. },
  213. // 确认选择时获取完整数据
  214. onPickerConfirm() {
  215. const [provinceIndex, cityIndex] = this.multiIndex;
  216. const selectedProvince = this.multiArray[0][provinceIndex];
  217. const selectedCity = this.multiArray[1][cityIndex];
  218. console.log("选中的省份完整数据:", selectedProvince);
  219. console.log("选中的城市完整数据:", selectedCity);
  220. },
  221. setSelectedCity(cityId) {
  222. for (let i = 0; i < this.allData.length; i++) {
  223. const province = this.allData[i];
  224. for (let j = 0; j < province.children.length; j++) {
  225. const city = province.children[j];
  226. if (city.id === cityId) {
  227. // 设置选中的省份和城市索引
  228. this.multiIndex = [i, j];
  229. // 更新 multiArray 的第二列(城市)
  230. const cities = province.children.map(city => ({
  231. label: city.lable,
  232. value: city.id,
  233. }));
  234. this.multiArray[1] = cities;
  235. // 强制更新视图
  236. this.$forceUpdate();
  237. return;
  238. }
  239. }
  240. }
  241. },
  242. checkAllFields() {
  243. const requiredFields = [{
  244. key: 'userName',
  245. name: '手机号'
  246. },
  247. {
  248. key: 'realName',
  249. name: '姓名'
  250. },
  251. {
  252. key: 'idCard',
  253. name: '身份证号'
  254. },
  255. {
  256. key: 'birthday',
  257. name: '生日'
  258. },
  259. // {
  260. // key: 'hometown',
  261. // name: '家乡',
  262. // type: 'array'
  263. // },
  264. // {
  265. // key: 'hujiDizhi',
  266. // name: '身份证地址'
  267. // },
  268. {
  269. key: 'gender',
  270. name: '性别'
  271. },
  272. // {
  273. // key: 'juzhuDizhi',
  274. // name: '通讯地址'
  275. // },
  276. {
  277. key: 'minzu',
  278. name: '民族',
  279. type: 'object'
  280. },
  281. {
  282. key: 'xueli',
  283. name: '学历',
  284. type: 'object'
  285. },
  286. // {
  287. // key: 'shuxiang',
  288. // name: '属相',
  289. // type: 'object'
  290. // },
  291. // {
  292. // key: 'xingzuo',
  293. // name: '星座',
  294. // type: 'object'
  295. // },
  296. ]
  297. for (const field of requiredFields) {
  298. const value = this.formData[field.key]
  299. // 根据不同类型进行存在验证
  300. if (field.type === 'array' && !value?.length) {
  301. this.showAlert(field.name)
  302. return false
  303. }
  304. if (field.type === 'object' && !Object.keys(value).length) {
  305. this.showAlert(field.name)
  306. return false
  307. }
  308. if (field.type === 'boolean' && value !== true) {
  309. this.showAlert(field.name)
  310. return false
  311. }
  312. if (!field.type && !value?.toString().trim()) {
  313. this.showAlert(field.name)
  314. return false
  315. }
  316. }
  317. return true
  318. },
  319. showAlert(fieldName) {
  320. uni.showToast({
  321. title: `${fieldName}不能为空`,
  322. icon: 'none',
  323. duration: 2000
  324. })
  325. },
  326. getXueli() {
  327. getJiazhengXueli({}).then(res => {
  328. this.xueliList = res.data
  329. // console.log('xueliList', this.xueliList);
  330. }).catch(error => {
  331. console.error('获取技能类型失败:', error);
  332. });
  333. },
  334. getXingzuo() {
  335. getJiazhengXingzuo({}).then(res => {
  336. this.xingzuoList = res.data
  337. // console.log('xingzuoList', this.xingzuoList);
  338. }).catch(error => {
  339. console.error('获取技能类型失败:', error);
  340. });
  341. },
  342. getShuxiang() {
  343. getJiazhengShuxiang({}).then(res => {
  344. this.shuxiangList = res.data
  345. // console.log('shuxiangList', this.shuxiangList);
  346. }).catch(error => {
  347. console.error('获取技能类型失败:', error);
  348. });
  349. },
  350. getHunyin() {
  351. getJiazhengHunyin({}).then(res => {
  352. this.hunyinList = res.data
  353. // console.log('hunyinList', this.hunyinList);
  354. }).catch(error => {
  355. console.error('获取技能类型失败:', error);
  356. });
  357. },
  358. getMinzu() {
  359. getJiazhengMinzu({}).then(res => {
  360. this.minzuList = res.data
  361. // console.log('minzuList', this.minzuList);
  362. }).catch(error => {
  363. console.error('获取技能类型失败:', error);
  364. });
  365. },
  366. getFileUrl(data) {
  367. this.formData.icon = data
  368. console.log('data', data);
  369. },
  370. minzuChange(e) {
  371. const index = e.detail.value
  372. this.formData.minzu = this.minzuList[index]
  373. //console.log('this.formData.minzu', this.formData.minzu);
  374. },
  375. minzuCancel() {
  376. this.formData.minzuIndex = 0
  377. },
  378. xingzuoChange(e) {
  379. const index = e.detail.value
  380. this.formData.xingzuo = this.xingzuoList[index]
  381. // console.log('this.formData.xingzuo', this.formData.xingzuo);
  382. },
  383. xingzuoCancel() {
  384. this.formData.xingzuoIndex = 0
  385. },
  386. shuxiangChange(e) {
  387. const index = e.detail.value
  388. this.formData.shuxiang = this.shuxiangList[index]
  389. //console.log('this.formData.shuxiang', this.formData.shuxiang);
  390. },
  391. shuxiangCancel() {
  392. this.formData.shuxiangIndex = 0
  393. },
  394. selectChangeXueliList(data) {
  395. this.formData.xueli = data
  396. },
  397. genderSelect(data) {
  398. this.formData.gender = data
  399. },
  400. selectChangeHunyinList(data) {
  401. this.formData.hunyin = data
  402. },
  403. switchXingzuoChange(e) {
  404. this.formData.xingzuoFlag = e.detail.value
  405. },
  406. goNext() {
  407. console.log('formData', this.formData);
  408. if (!this.checkAllFields()) {
  409. return false
  410. }
  411. if(!this.formData.agree){
  412. uni.showToast({
  413. title: "请勾选本人同意!",
  414. icon: 'none',
  415. duration: 2000
  416. })
  417. return false
  418. }
  419. this.$emit('goNext',this.formData,0);
  420. },
  421. handleAgree(e) {
  422. this.formData.agree = e.detail.value.length > 0
  423. },
  424. }
  425. }
  426. </script>