gerenZiliao.vue 14 KB

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