gerenZiliao.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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: 'shuxiang',
  284. name: '属相',
  285. type: 'object'
  286. },
  287. {
  288. key: 'xingzuo',
  289. name: '星座',
  290. type: 'object'
  291. },
  292. ]
  293. for (const field of requiredFields) {
  294. const value = this.formData[field.key]
  295. // 根据不同类型进行存在验证
  296. if (field.type === 'array' && !value?.length) {
  297. this.showAlert(field.name)
  298. return false
  299. }
  300. if (field.type === 'object' && !Object.keys(value).length) {
  301. this.showAlert(field.name)
  302. return false
  303. }
  304. if (field.type === 'boolean' && value !== true) {
  305. this.showAlert(field.name)
  306. return false
  307. }
  308. if (!field.type && !value?.toString().trim()) {
  309. this.showAlert(field.name)
  310. return false
  311. }
  312. }
  313. return true
  314. },
  315. showAlert(fieldName) {
  316. uni.showToast({
  317. title: `${fieldName}不能为空`,
  318. icon: 'none',
  319. duration: 2000
  320. })
  321. },
  322. getXueli() {
  323. getJiazhengXueli({}).then(res => {
  324. this.xueliList = res.data
  325. // console.log('xueliList', this.xueliList);
  326. }).catch(error => {
  327. console.error('获取技能类型失败:', error);
  328. });
  329. },
  330. getXingzuo() {
  331. getJiazhengXingzuo({}).then(res => {
  332. this.xingzuoList = res.data
  333. // console.log('xingzuoList', this.xingzuoList);
  334. }).catch(error => {
  335. console.error('获取技能类型失败:', error);
  336. });
  337. },
  338. getShuxiang() {
  339. getJiazhengShuxiang({}).then(res => {
  340. this.shuxiangList = res.data
  341. // console.log('shuxiangList', this.shuxiangList);
  342. }).catch(error => {
  343. console.error('获取技能类型失败:', error);
  344. });
  345. },
  346. getHunyin() {
  347. getJiazhengHunyin({}).then(res => {
  348. this.hunyinList = res.data
  349. // console.log('hunyinList', this.hunyinList);
  350. }).catch(error => {
  351. console.error('获取技能类型失败:', error);
  352. });
  353. },
  354. getMinzu() {
  355. getJiazhengMinzu({}).then(res => {
  356. this.minzuList = res.data
  357. // console.log('minzuList', this.minzuList);
  358. }).catch(error => {
  359. console.error('获取技能类型失败:', error);
  360. });
  361. },
  362. getFileUrl(data) {
  363. this.formData.icon = data
  364. console.log('data', data);
  365. },
  366. minzuChange(e) {
  367. const index = e.detail.value
  368. this.formData.minzu = this.minzuList[index]
  369. //console.log('this.formData.minzu', this.formData.minzu);
  370. },
  371. minzuCancel() {
  372. this.formData.minzuIndex = 0
  373. },
  374. xingzuoChange(e) {
  375. const index = e.detail.value
  376. this.formData.xingzuo = this.xingzuoList[index]
  377. // console.log('this.formData.xingzuo', this.formData.xingzuo);
  378. },
  379. xingzuoCancel() {
  380. this.formData.xingzuoIndex = 0
  381. },
  382. shuxiangChange(e) {
  383. const index = e.detail.value
  384. this.formData.shuxiang = this.shuxiangList[index]
  385. //console.log('this.formData.shuxiang', this.formData.shuxiang);
  386. },
  387. shuxiangCancel() {
  388. this.formData.shuxiangIndex = 0
  389. },
  390. selectChangeXueliList(data) {
  391. console.log('data', data);
  392. },
  393. genderSelect(data) {
  394. this.formData.gender = data
  395. },
  396. selectChangeHunyinList(data) {
  397. this.formData.hunyin = data
  398. },
  399. switchXingzuoChange(e) {
  400. this.formData.xingzuoFlag = e.detail.value
  401. },
  402. goNext() {
  403. console.log('formData', this.formData);
  404. if (!this.checkAllFields()) return
  405. this.$emit('goNext', 0);
  406. },
  407. handleAgree(e) {
  408. this.formData.agree = e.detail.value.length > 0
  409. },
  410. }
  411. }
  412. </script>