gerenZiliao.vue 16 KB

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