gerenZiliao.vue 14 KB

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