Personal.vue 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808
  1. <template>
  2. <view class="personal-container">
  3. <!-- Add loading indicator -->
  4. <view class="loading-container" v-if="isLoading">
  5. <view class="loading-spinner"></view>
  6. <text class="loading-text">加载中...</text>
  7. </view>
  8. <!-- 添加承诺书弹框 -->
  9. <view class="promise-modal" v-if="showPromiseModal">
  10. <view class="promise-content">
  11. <view class="promise-title">入职承诺书</view>
  12. <scroll-view scroll-y class="promise-text">
  13. <text>
  14. 本人郑重承诺:
  15. 所提交的入职登记表、学历证书、职业资格证明、工作履历等全部个人信息及证明材料均真实、准确、完整。若经公司核查发现存在虚构工作经历、伪造学历证书、隐瞒竞业限制义务、虚报健康状况等任何不实或欺诈情形,本人自愿承担以下责任:
  16. 1. 法律责任:因信息不实引发的劳动纠纷、民事赔偿、行政处罚或刑事追责,由本人独立承担全部法律后果,公司不承担任何连带责任;
  17. 2. 劳动关系处理:公司有权立即解除劳动合同,无需支付经济补偿,并保留向本人追偿因信息欺诈导致公司经济损失(包括但不限于招聘成本、培训费用、商誉损失等)的权利;
  18. 3. 其他后果:若已入职,公司可单方撤销录用决定,要求返还已发放的工资、福利等费用,并可将不实行为记入个人档案。
  19. 本人确认已充分理解上述条款内容,无任何歧义,并自愿受其约束。
  20. </text>
  21. </scroll-view>
  22. <view class="promise-checkbox">
  23. <checkbox :checked="promiseChecked" @click="togglePromiseChecked" />
  24. <text>我已阅读并同意以上承诺书内容</text>
  25. </view>
  26. <view class="promise-buttons">
  27. <button class="promise-btn confirm-btn" :disabled="!promiseChecked" @click="confirmPromise">确认</button>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="form-title">个人信息表</view>
  32. <!-- 添加步骤指示器 -->
  33. <!-- <view class="steps-indicator">
  34. <view
  35. v-for="(step, index) in steps"
  36. :key="step.id"
  37. class="step-item"
  38. :class="{ 'active': currentStep >= step.id, 'current': currentStep === step.id }"
  39. >
  40. <view class="step-number">{{ step.id }}</view>
  41. <view class="step-name">{{ step.name }}</view>
  42. </view>
  43. </view> -->
  44. <!-- 根据currentStep渲染对应的表单内容 -->
  45. <view class="form-content">
  46. <!-- 第一步:基本信息 -->
  47. <view v-if="currentStep === 1" class="form-container">
  48. <!-- 第一行 -->
  49. <view class="form-row">
  50. <view class="form-item" v-if="showNameField">
  51. <text class="label required">姓名</text>
  52. <input type="text" v-model="formData.name" placeholder="请输入姓名" :class="{'input-error': formErrors.name}" />
  53. <text v-if="formErrors.name" class="error-message">{{formErrors.name}}</text>
  54. </view>
  55. <view class="form-item" v-if="showGenderField">
  56. <text class="label required">性别</text>
  57. <picker @change="bindGenderChange" :value="genderIndex" :range="genderOptions">
  58. <view class="picker-text" :class="{'input-error': formErrors.gender}">{{ genderOptions[genderIndex] || '请选择性别' }}</view>
  59. </picker>
  60. <text v-if="formErrors.gender" class="error-message">{{formErrors.gender}}</text>
  61. </view>
  62. <!-- 当性别为女时显示三期选择 -->
  63. <view class="form-row" v-if="formData.gender === '女'">
  64. <view class="form-item" >
  65. <text class="label required">是否为三期</text>
  66. <picker @change="bindThreePeriodChange" :value="threePeriodIndex" :range="threePeriodOptions" :class="{'input-error': formErrors.threePeriod}">
  67. <view class="picker-text">{{ threePeriodOptions[threePeriodIndex] || '请选择' }}</view>
  68. </picker>
  69. <text v-if="formErrors.threePeriod" class="error-message">{{formErrors.threePeriod}}</text>
  70. </view>
  71. </view>
  72. <view class="form-row">
  73. <view class="form-item" v-if="showPhoneField">
  74. <text class="label required">手机号</text>
  75. <input
  76. type="number"
  77. v-model="formData.phone"
  78. placeholder="请输入手机号"
  79. :class="{'input-error': formErrors.phone}"
  80. maxlength="11"
  81. @input="validatePhone"
  82. />
  83. <text v-if="formErrors.phone" class="error-message">{{formErrors.phone}}</text>
  84. </view>
  85. </view>
  86. <!-- <view class="form-item">
  87. <text class="label">出生日期</text>
  88. <picker mode="date" :value="formData.birthDate" @change="bindDateChange">
  89. <view class="picker-text">{{ formData.birthDate || '请选择日期' }}</view>
  90. </picker>
  91. </view> -->
  92. </view>
  93. <view class="form-item" v-if="showIdCardField">
  94. <text class="label required">身份证号</text>
  95. <input type="idcard" v-model="formData.idCard" placeholder="请输入身份证号" :class="{'input-error': formErrors.idCard}" />
  96. <text v-if="formErrors.idCard" class="error-message">{{formErrors.idCard}}</text>
  97. </view>
  98. <!-- <view class="form-item">
  99. <text class="label">政治面貌</text>
  100. <picker @change="bindPoliticalChange" :value="politicalIndex" :range="politicalOptions">
  101. <view class="picker-text">{{ politicalOptions[politicalIndex] || '请选择政治面貌' }}</view>
  102. </picker>
  103. </view> -->
  104. <view class="form-item" v-if="showEthnicField">
  105. <text class="label required">民族</text>
  106. <picker @change="bindEthnicChange" :value="ethnicIndex" :range="ethnicOptions">
  107. <view class="picker-text" :class="{'input-error': formErrors.ethnic}">{{ ethnicOptions[ethnicIndex] || '请选择民族' }}</view>
  108. </picker>
  109. <text v-if="formErrors.ethnic" class="error-message">{{formErrors.ethnic}}</text>
  110. </view>
  111. <!-- 第三行 -->
  112. <view class="form-row">
  113. <view class="form-item" v-if="showHeightField">
  114. <text class="label">身高(cm)</text>
  115. <input type="digit" step="0.01" v-model="formData.height"
  116. @input="handleInput($event, 'height', 2)"
  117. @blur="handleBlur('height')" placeholder="请输入身高" />
  118. </view>
  119. <view class="form-item" v-if="showWeightField">
  120. <text class="label">体重(kg)</text>
  121. <input type="digit" step="0.01" v-model="formData.weight"
  122. @input="handleInput($event, 'weight', 2)"
  123. @blur="handleBlur('weight')"
  124. placeholder="请输入体重" />
  125. </view>
  126. <view class="form-item" v-if="showCurrentAddress">
  127. <text class="label required">现居住地址</text>
  128. <input type="text" v-model="formData.currentAddress" placeholder="请输入现居住地址" :class="{'input-error': formErrors.currentAddress}" />
  129. <text v-if="formErrors.currentAddress" class="error-message">{{formErrors.currentAddress}}</text>
  130. </view>
  131. <!-- <view class="form-item">
  132. <text class="label">籍贯</text>
  133. <input type="text" v-model="formData.nativePlace" placeholder="请输入籍贯" />
  134. </view> -->
  135. </view>
  136. <!-- 第四行 -->
  137. <view class="form-row">
  138. <view class="form-item" v-if="showResidence">
  139. <text class="label">户口所在地</text>
  140. <input type="text" v-model="formData.residence" placeholder="请输入户口所在地" />
  141. </view>
  142. <view class="form-item" v-if="showMarriageIndex">
  143. <text class="label">婚育状况</text>
  144. <picker @change="bindMarriageChange" :value="marriageIndex" :range="marriageOptions">
  145. <view class="picker-text">{{ marriageOptions[marriageIndex] || '请选择婚育状况' }}</view>
  146. </picker>
  147. </view>
  148. <view class="form-item" v-if="showExpectedSalary">
  149. <text class="label">期望薪资(元/月)</text>
  150. <input
  151. type="number"
  152. v-model="formData.expectedSalary"
  153. placeholder="请输入期望薪资"
  154. @change="validateExpectedSalary"
  155. :class="{'input-error': formErrors.expectedSalary}"
  156. max="100000"
  157. />
  158. <text v-if="formErrors.expectedSalary" class="error-message">{{formErrors.expectedSalary}}</text>
  159. </view>
  160. </view>
  161. </view>
  162. <!-- 第二步:家庭成员 -->
  163. <view v-if="currentStep === 3" class="form-container">
  164. <view class="section-title">家庭主要成员信息</view>
  165. <!-- 已添加的家庭成员列表 -->
  166. <view class="family-members-list" v-if="familyMembers.length > 0">
  167. <view class="family-member-item" v-for="(member, index) in familyMembers" :key="index">
  168. <view class="family-member-header">
  169. <text class="family-member-title">成员 {{index + 1}}</text>
  170. <view class="family-member-actions">
  171. <text class="family-member-edit" @click="editFamilyMember(index)">编辑</text>
  172. <text class="family-member-delete" @click="deleteFamilyMember(index)">删除</text>
  173. </view>
  174. </view>
  175. <view class="family-member-content">
  176. <view class="family-member-row" v-if="showFamilyRelationField">
  177. <text class="family-member-label">称谓:</text>
  178. <text class="family-member-value">{{member.relation}}</text>
  179. </view>
  180. <view class="family-member-row" v-if="showFamilyNameField">
  181. <text class="family-member-label">姓名:</text>
  182. <text class="family-member-value">{{member.name}}</text>
  183. </view>
  184. <view class="family-member-row" v-if="showFamilyWorkplaceField">
  185. <text class="family-member-label">工作单位/家庭地址:</text>
  186. <text class="family-member-value">{{member.workplaceOrAddress}}</text>
  187. </view>
  188. <view class="family-member-row" v-if="showFamilyPositionField">
  189. <text class="family-member-label">职务:</text>
  190. <text class="family-member-value">{{member.position}}</text>
  191. </view>
  192. <view class="family-member-row" v-if="showFamilyPhoneField">
  193. <text class="family-member-label">联系电话:</text>
  194. <text class="family-member-value">{{member.phone}}</text>
  195. </view>
  196. <view class="family-member-row">
  197. <text class="family-member-label">是否为紧急联系人:</text>
  198. <text class="family-member-value">{{member.isEmergencyContact ? '是' : '否'}}</text>
  199. </view>
  200. </view>
  201. </view>
  202. </view>
  203. <!-- 家庭成员信息表单 -->
  204. <view class="family-member-form">
  205. <view class="form-subtitle">
  206. {{ isEditing ? '编辑家庭成员' : '添加家庭成员' }}
  207. <text v-if="isEditing" class="cancel-edit" @click="cancelEdit">取消编辑</text>
  208. </view>
  209. <view class="form-row">
  210. <view class="form-item" v-if="showFamilyRelationField">
  211. <text class="label required">称谓</text>
  212. <input
  213. type="text"
  214. v-model="familyMemberForm.relation"
  215. placeholder="如:父亲、母亲、配偶等"
  216. :class="{'input-error': familyMemberErrors.relation}"
  217. />
  218. <text v-if="familyMemberErrors.relation" class="error-message">{{familyMemberErrors.relation}}</text>
  219. </view>
  220. <view class="form-item" v-if="showFamilyNameField">
  221. <text class="label required">姓名</text>
  222. <input
  223. type="text"
  224. v-model="familyMemberForm.name"
  225. placeholder="请输入姓名"
  226. :class="{'input-error': familyMemberErrors.name}"
  227. />
  228. <text v-if="familyMemberErrors.name" class="error-message">{{familyMemberErrors.name}}</text>
  229. </view>
  230. </view>
  231. <view class="form-row">
  232. <view class="form-item" v-if="showFamilyWorkplaceField">
  233. <text class="label ">工作单位/家庭地址</text>
  234. <input type="text" v-model="familyMemberForm.workplaceOrAddress" placeholder="请输入工作单位或家庭地址" />
  235. <!-- <text v-if="familyMemberErrors.workplaceOrAddress" class="error-message">{{familyMemberErrors.workplaceOrAddress}}</text> -->
  236. </view>
  237. <view class="form-item" v-if="showFamilyPositionField">
  238. <text class="label ">职务</text>
  239. <input type="text" v-model="familyMemberForm.position" placeholder="请输入职务" />
  240. <!-- <text v-if="familyMemberErrors.position" class="error-message">{{familyMemberErrors.position}}</text> -->
  241. </view>
  242. </view>
  243. <view class="form-row">
  244. <view class="form-item" v-if="showFamilyPhoneField">
  245. <!-- required -->
  246. <text class="label">联系电话</text>
  247. <input
  248. type="number"
  249. v-model="familyMemberForm.phone"
  250. placeholder="请输入联系电话"
  251. maxlength="11"
  252. @input="validatePhone"
  253. :class="{'input-error': familyMemberErrors.phone}"
  254. />
  255. <text v-if="familyMemberErrors.phone" class="error-message">{{familyMemberErrors.phone}}</text>
  256. </view>
  257. </view>
  258. <view class="form-row" v-if="showFamilyisEmergency">
  259. <view class="form-item">
  260. <text class="label">是否为紧急联系人</text>
  261. <switch :checked="familyMemberForm.isEmergencyContact" @change="handleEmergencyContactChange" />
  262. </view>
  263. </view>
  264. <view class="form-row button-row">
  265. <view class="form-item button-container">
  266. <button class="circle-btn" @click="saveFamilyMember">
  267. <text class="btn-icon">{{ isEditing ? '✓' : '+' }}</text>
  268. </button>
  269. <text class="btn-text">{{ isEditing ? '保存修改' : '添加成员' }}</text>
  270. </view>
  271. </view>
  272. </view>
  273. </view>
  274. <!-- 第三步:教育经历 -->
  275. <view v-if="currentStep === 5" class="form-container">
  276. <view class="section-title">教育经历</view>
  277. <!-- 已添加的教育经历列表 -->
  278. <view class="education-list" v-if="educationList.length > 0">
  279. <view class="education-item" v-for="(edu, index) in educationList" :key="index">
  280. <view class="education-header">
  281. <text class="education-title">{{ index === 0 ? '第一学历' : '最高学历' }}</text>
  282. <view class="education-actions">
  283. <text class="education-edit" @click="editEducation(index)">编辑</text>
  284. <text class="education-delete" @click="deleteEducation(index)">删除</text>
  285. </view>
  286. </view>
  287. <view class="education-content">
  288. <view class="education-row" v-if="showEducationTimeField">
  289. <text class="education-label">起止时间:</text>
  290. <text class="education-value">{{edu.startTime}} 至 {{edu.endTime}}</text>
  291. </view>
  292. <view class="education-row" v-if="showEducationSchoolField">
  293. <text class="education-label">学校名称:</text>
  294. <text class="education-value">{{edu.schoolName}}</text>
  295. </view>
  296. <view class="education-row" v-if="showEducationMajorField">
  297. <text class="education-label">专业:</text>
  298. <text class="education-value">{{edu.major}}</text>
  299. </view>
  300. <view class="education-row" v-if="showEducationDegreeField">
  301. <text class="education-label">学历:</text>
  302. <text class="education-value">{{edu.degree}}</text>
  303. </view>
  304. </view>
  305. </view>
  306. </view>
  307. <!-- 教育经历表单 -->
  308. <view class="education-form" v-if="educationList.length < 2 || isEditingEducation">
  309. <view class="form-subtitle">
  310. {{ isEditingEducation ? '编辑教育经历' : (educationList.length === 0 ? '添加第一学历' : '添加最高学历') }}
  311. <text v-if="isEditingEducation" class="cancel-edit" @click="cancelEditEducation">取消编辑</text>
  312. </view>
  313. <view class="form-row">
  314. <view class="form-item" v-if="showEducationTimeField">
  315. <text class="label required">起止时间</text>
  316. <view class="date-range">
  317. <picker
  318. mode="date"
  319. :value="educationForm.startTime"
  320. @change="bindStartTimeChange"
  321. :class="{'input-error': educationErrors.startTime}"
  322. >
  323. <view class="picker-text">{{ educationForm.startTime || '开始时间' }}</view>
  324. </picker>
  325. <text class="date-separator">至</text>
  326. <picker
  327. mode="date"
  328. :value="educationForm.endTime"
  329. @change="bindEndTimeChange"
  330. :class="{'input-error': educationErrors.endTime}"
  331. >
  332. <view class="picker-text">{{ educationForm.endTime || '结束时间' }}</view>
  333. </picker>
  334. </view>
  335. <text v-if="educationErrors.startTime" class="error-message">{{educationErrors.startTime}}</text>
  336. <text v-if="educationErrors.endTime" class="error-message">{{educationErrors.endTime}}</text>
  337. </view>
  338. </view>
  339. <view class="form-row">
  340. <view class="form-item" v-if="showEducationSchoolField">
  341. <text class="label required">学校名称</text>
  342. <input
  343. type="text"
  344. v-model="educationForm.schoolName"
  345. placeholder="请输入学校名称"
  346. :class="{'input-error': educationErrors.schoolName}"
  347. />
  348. <text v-if="educationErrors.schoolName" class="error-message">{{educationErrors.schoolName}}</text>
  349. </view>
  350. <view class="form-item" v-if="showEducationMajorField">
  351. <text class="label required">专业</text>
  352. <input
  353. type="text"
  354. v-model="educationForm.major"
  355. placeholder="请输入专业"
  356. :class="{'input-error': educationErrors.major}"
  357. />
  358. <text v-if="educationErrors.major" class="error-message">{{educationErrors.major}}</text>
  359. </view>
  360. </view>
  361. <view class="form-row">
  362. <view class="form-item" v-if="showEducationDegreeField">
  363. <text class="label required">学历</text>
  364. <picker
  365. @change="bindDegreeChange"
  366. :value="degreeIndex"
  367. :range="degreeOptions"
  368. :class="{'input-error': educationErrors.degree}"
  369. >
  370. <view class="picker-text">{{ degreeOptions[degreeIndex] || '请选择学历' }}</view>
  371. </picker>
  372. <text v-if="educationErrors.degree" class="error-message">{{educationErrors.degree}}</text>
  373. </view>
  374. </view>
  375. <view class="form-row button-row">
  376. <view class="form-item button-container">
  377. <button class="circle-btn" @click="saveEducation">
  378. <text class="btn-icon">{{ isEditingEducation ? '✓' : '+' }}</text>
  379. </button>
  380. <text class="btn-text">{{ isEditingEducation ? '保存修改' : '添加学历' }}</text>
  381. </view>
  382. </view>
  383. </view>
  384. </view>
  385. <!-- 第四步:专业技能 -->
  386. <view v-if="currentStep === 6 && (showRequireTrainingInfoField || showRequireProfessionalSkillsField)" class="form-container">
  387. <view class="section-title" v-if="showRequireTrainingInfoField"><text class="required" style="margin-right: 4rpx;color: #ff4d4f;">*</text>专业技能</view>
  388. <view class="skills-container" v-if="showRequireTrainingInfoField">
  389. <textarea
  390. v-model="formData.skills"
  391. placeholder="请描述您的专业技能"
  392. class="skills-textarea"
  393. :class="{'input-error': formErrors.skills}"
  394. maxlength="500"
  395. ></textarea>
  396. <text v-if="formErrors.skills" class="error-message">{{formErrors.skills}}</text>
  397. </view>
  398. <view class="section-title" v-if="showRequireProfessionalSkillsField"><text class="required" style="margin-right: 4rpx;color: #ff4d4f;">*</text>培训经历</view>
  399. <view class="training-container" v-if="showRequireProfessionalSkillsField">
  400. <textarea
  401. v-model="formData.training"
  402. placeholder="请填写您接受过的培训经历"
  403. class="training-textarea"
  404. :class="{'input-error': formErrors.training}"
  405. maxlength="500"
  406. ></textarea>
  407. <text v-if="formErrors.training" class="error-message">{{formErrors.training}}</text>
  408. </view>
  409. </view>
  410. <!-- 第五步:工作经历 -->
  411. <view v-if="currentStep === 8" class="form-container">
  412. <view class="section-title">工作经历</view>
  413. <!-- 已添加的工作经历列表 -->
  414. <view class="work-list" v-if="workList.length > 0">
  415. <view class="work-item" v-for="(work, index) in workList" :key="index">
  416. <view class="work-header">
  417. <text class="work-title">单位{{ index + 1 }}</text>
  418. <view class="work-actions">
  419. <text class="work-edit" @click="editWork(index)">编辑</text>
  420. <text class="work-delete" @click="deleteWork(index)">删除</text>
  421. </view>
  422. </view>
  423. <view class="work-content">
  424. <view class="work-row" v-if="showWorkTimeField">
  425. <text class="work-label">起止时间:</text>
  426. <text class="work-value">{{work.startTime}} 至 {{work.endTime}}</text>
  427. </view>
  428. <view class="work-row" v-if="showWorkCompanyField">
  429. <text class="work-label">单位名称:</text>
  430. <text class="work-value">{{work.companyName}}</text>
  431. </view>
  432. <view class="work-row" v-if="showWorkDepartmentField">
  433. <text class="work-label">任职部门:</text>
  434. <text class="work-value">{{work.department}}</text>
  435. </view>
  436. <view class="work-row" v-if="showWorkEmployeeCountField">
  437. <text class="work-label">单位人数:</text>
  438. <text class="work-value">{{work.employeeCount}}</text>
  439. </view>
  440. <view class="work-row" v-if="showWorkPositionField">
  441. <text class="work-label">担任职务:</text>
  442. <text class="work-value">{{work.position}}</text>
  443. </view>
  444. <view class="work-row" v-if="showWorkMonthlySalary">
  445. <text class="work-label">月总收入:</text>
  446. <text class="work-value">{{work.monthlySalary}}</text>
  447. </view>
  448. <view class="work-row" v-if="showWorkSupervisor">
  449. <text class="work-label" >直接领导:</text>
  450. <text class="work-value">{{work.supervisor}}</text>
  451. </view>
  452. <view class="work-row" v-if="showWorkSupervisorPhone">
  453. <text class="work-label">领导电话:</text>
  454. <text class="work-value">{{work.supervisorPhone}}</text>
  455. </view>
  456. </view>
  457. </view>
  458. </view>
  459. <!-- 工作经历表单 -->
  460. <view class="work-form" v-if="workList.length < 2 || isEditingWork">
  461. <view class="form-subtitle">
  462. {{ isEditingWork ? '编辑工作经历' : '添加工作经历' }}
  463. <text v-if="isEditingWork" class="cancel-edit" @click="cancelEditWork">取消编辑</text>
  464. </view>
  465. <view class="form-row">
  466. <view class="form-item" v-if="showWorkTimeField">
  467. <text class="label required">起止时间</text>
  468. <view class="date-range">
  469. <picker
  470. mode="date"
  471. :value="workForm.startTime"
  472. @change="bindWorkStartTimeChange"
  473. :class="{'input-error': workErrors.startTime}"
  474. >
  475. <view class="picker-text">{{ workForm.startTime || '开始时间' }}</view>
  476. </picker>
  477. <text class="date-separator">至</text>
  478. <picker
  479. mode="date"
  480. :value="workForm.endTime"
  481. @change="bindWorkEndTimeChange"
  482. :class="{'input-error': workErrors.endTime}"
  483. >
  484. <view class="picker-text">{{ workForm.endTime || '结束时间' }}</view>
  485. </picker>
  486. </view>
  487. <text v-if="workErrors.startTime" class="error-message">{{workErrors.startTime}}</text>
  488. <text v-if="workErrors.endTime" class="error-message">{{workErrors.endTime}}</text>
  489. </view>
  490. </view>
  491. <view class="form-row">
  492. <view class="form-item" v-if="showWorkCompanyField">
  493. <text class="label required">单位名称</text>
  494. <input
  495. type="text"
  496. v-model="workForm.companyName"
  497. placeholder="请输入单位名称"
  498. :class="{'input-error': workErrors.companyName}"
  499. />
  500. <text v-if="workErrors.companyName" class="error-message">{{workErrors.companyName}}</text>
  501. </view>
  502. <view class="form-item" v-if="showWorkEmployeeCountField">
  503. <text class="label required">单位人数</text>
  504. <input
  505. type="number"
  506. v-model="workForm.employeeCount"
  507. placeholder="请输入单位人数"
  508. :class="{'input-error': workErrors.employeeCount}"
  509. max="10000"
  510. @change="validateEmployeeCount"
  511. />
  512. <text v-if="workErrors.employeeCount" class="error-message">{{workErrors.employeeCount}}</text>
  513. </view>
  514. </view>
  515. <view class="form-row">
  516. <view class="form-item" v-if="showWorkDepartmentField">
  517. <text class="label required">任职部门</text>
  518. <input
  519. type="text"
  520. v-model="workForm.department"
  521. placeholder="请输入任职部门"
  522. :class="{'input-error': workErrors.department}"
  523. />
  524. <text v-if="workErrors.department" class="error-message">{{workErrors.department}}</text>
  525. </view>
  526. <view class="form-item" v-if="showWorkPositionField">
  527. <text class="label required">担任职务</text>
  528. <input
  529. type="text"
  530. v-model="workForm.position"
  531. placeholder="请输入担任职务"
  532. :class="{'input-error': workErrors.position}"
  533. />
  534. <text v-if="workErrors.position" class="error-message">{{workErrors.position}}</text>
  535. </view>
  536. </view>
  537. <view class="form-row">
  538. <view class="form-item" v-if="showWorkMonthlySalary">
  539. <text class="label required">月总收入</text>
  540. <input
  541. type="number"
  542. v-model="workForm.monthlySalary"
  543. placeholder="请输入月总收入"
  544. :class="{'input-error': workErrors.monthlySalary}"
  545. max="100000"
  546. min="0"
  547. @input="validateMonthlySalary"
  548. />
  549. <text v-if="workErrors.monthlySalary" class="error-message">{{workErrors.monthlySalary}}</text>
  550. </view>
  551. </view>
  552. <view class="form-row">
  553. <view class="form-item" v-if="showWorkSupervisor">
  554. <text class="label required">直接领导</text>
  555. <input type="text" v-model="workForm.supervisor" placeholder="请输入直接领导姓名" />
  556. <text v-if="workErrors.supervisor" class="error-message">{{workErrors.supervisor}}</text>
  557. </view>
  558. <view class="form-item" v-if="showWorkSupervisorPhone">
  559. <text class="label">领导电话</text>
  560. <input
  561. type="number"
  562. v-model="workForm.supervisorPhone"
  563. maxlength="11"
  564. placeholder="请输入领导电话"
  565. @input="validatePhone"
  566. />
  567. <text v-if="workErrors.supervisorPhone" class="error-message">{{workErrors.supervisorPhone}}</text>
  568. </view>
  569. </view>
  570. <view class="form-row button-row">
  571. <view class="form-item button-container">
  572. <button class="circle-btn" @click="saveWork">
  573. <text class="btn-icon">{{ isEditingWork ? '✓' : '+' }}</text>
  574. </button>
  575. <text class="btn-text">{{ isEditingWork ? '保存修改' : '添加工作经历' }}</text>
  576. </view>
  577. </view>
  578. </view>
  579. </view>
  580. </view>
  581. <!-- 修改导航按钮逻辑 -->
  582. <view class="nav-buttons">
  583. <button
  584. v-if="showPrevButton"
  585. class="nav-btn prev-btn"
  586. @click="prevStep"
  587. >上一步</button>
  588. <button
  589. v-if="showSubmitButton"
  590. class="submit-btn"
  591. @click="submitForm"
  592. >提交</button>
  593. <button
  594. v-else
  595. class="nav-btn next-btn"
  596. @click="nextStep"
  597. >下一步</button>
  598. <!-- v-if="showNextButton" -->
  599. </view>
  600. </view>
  601. </template>
  602. <script>
  603. import { apiBaseUrl } from '@/common/config.js';
  604. export default {
  605. data() {
  606. return {
  607. // 添加承诺书相关数据
  608. showPromiseModal: true,
  609. promiseChecked: false,
  610. formData: {
  611. name: '',
  612. gender: '',
  613. threePeriod: '',
  614. birthDate: '',
  615. idCard: '',
  616. political: '',
  617. ethnic: '',
  618. height: '',
  619. weight: '',
  620. nativePlace: '',
  621. residence: '',
  622. marriage: '',
  623. expectedSalary: '',
  624. phone: '',
  625. email: '',
  626. currentAddress: '',
  627. emergencyContact: '',
  628. emergencyPhone: '',
  629. hobby: '',
  630. motto: '',
  631. // 添加应聘来源相关字段
  632. sourceType: 'social', // 默认为社招
  633. socialSource: '', // 社招来源
  634. otherSocialSource: '', // 其他社招来源
  635. otherSchoolSource: '', // 其他学校来源
  636. // 添加技能和培训字段
  637. skills: '',
  638. training: '',
  639. },
  640. genderOptions: ['男', '女'],
  641. genderIndex: -1,
  642. threePeriodOptions: ['无', '孕期', '产期', '哺乳期'],
  643. threePeriodIndex: -1,
  644. politicalOptions: ['群众', '共青团员', '中共党员', '民主党派'],
  645. politicalIndex: -1,
  646. ethnicOptions: ['汉族', '壮族', '回族', '满族', '维吾尔族', '苗族', '彝族', '土家族', '藏族', '蒙古族', '侗族', '布依族', '瑶族', '白族', '朝鲜族', '哈尼族', '黎族', '哈萨克族', '傣族', '畲族', '其他'],
  647. ethnicIndex: -1,
  648. marriageOptions: ['未婚', '已婚', '离异', '丧偶'],
  649. marriageIndex: -1,
  650. familyMembers: [],
  651. familyMemberForm: {
  652. relation: '',
  653. name: '',
  654. workplaceOrAddress: '',
  655. position: '',
  656. phone: '',
  657. isEmergencyContact: false // 添加新字段
  658. },
  659. isEditing: false,
  660. editingIndex: -1,
  661. // 添加教育经历相关数据
  662. educationList: [],
  663. educationForm: {
  664. startTime: '',
  665. endTime: '',
  666. schoolName: '',
  667. major: '',
  668. degree: ''
  669. },
  670. isEditingEducation: false,
  671. editingEducationIndex: -1,
  672. degreeOptions: ['高中', '中专', '大专', '本科', '硕士', '博士'],
  673. degreeIndex: -1,
  674. // 添加工作经历相关数据
  675. workList: [],
  676. workForm: {
  677. startTime: '',
  678. endTime: '',
  679. companyName: '',
  680. department: '',
  681. employeeCount: '',
  682. position: '',
  683. monthlySalary: '',
  684. supervisor: '',
  685. supervisorPhone: ''
  686. },
  687. isEditingWork: false,
  688. editingWorkIndex: -1,
  689. // 添加步骤控制
  690. currentStep: 1,
  691. steps: [
  692. { id: 1, name: '基本信息' },
  693. { id: 3, name: '家庭成员' },
  694. { id: 5, name: '教育经历' },
  695. { id: 6, name: '专业技能' },
  696. { id: 8, name: '工作经历' }
  697. ],
  698. formErrors: {
  699. name: '',
  700. idCard: '',
  701. phone: '',
  702. gender: '',
  703. ethnic: '',
  704. currentAddress: '',
  705. height: '',
  706. weight: '',
  707. expectedSalary: '',
  708. skills: '',
  709. training: '',
  710. threePeriod: '' // 添加这一行
  711. },
  712. // Add loading state
  713. isLoading: true,
  714. familyMemberErrors: {
  715. relation: '',
  716. name: '',
  717. phone: '',
  718. workplaceOrAddress: '',
  719. position: ''
  720. },
  721. workErrors: {
  722. startTime: '',
  723. endTime: '',
  724. companyName: '',
  725. department: '',
  726. position: '',
  727. employeeCount: '',
  728. monthlySalary: '',
  729. supervisor: '',
  730. supervisorPhone: ''
  731. },
  732. // 在 data 中添加教育经历的错误提示对象
  733. educationErrors: {
  734. startTime: '',
  735. endTime: '',
  736. schoolName: '',
  737. major: '',
  738. degree: ''
  739. },
  740. // 添加统一的验证规则
  741. validationRules: {
  742. name: {
  743. required: true,
  744. message: '请输入姓名'
  745. },
  746. phone: {
  747. required: true,
  748. pattern: /^1[3-9]\d{9}$/,
  749. message: '请输入正确的手机号码',
  750. maxLength: 11
  751. },
  752. idCard: {
  753. required: true,
  754. pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
  755. message: '请输入正确的身份证号码'
  756. },
  757. gender: {
  758. required: true,
  759. message: '请选择性别'
  760. },
  761. ethnic: {
  762. required: true,
  763. message: '请选择民族'
  764. },
  765. currentAddress: {
  766. required: true,
  767. message: '请输入现居住地址'
  768. },
  769. height: {
  770. pattern: /^\d+(\.\d{1,2})?$/,
  771. message: '请输入正确的身高(cm)'
  772. },
  773. weight: {
  774. pattern: /^\d+(\.\d{1,2})?$/,
  775. message: '请输入正确的体重(kg)'
  776. },
  777. expectedSalary: {
  778. pattern: /^\d+(\.\d{1,2})?$/,
  779. message: '请输入正确的期望薪资'
  780. }
  781. },
  782. // 获取配置信息
  783. configData: (() => {
  784. try {
  785. const configStr = uni.getStorageSync('configData');
  786. if (configStr && configStr.trim()) {
  787. return JSON.parse(configStr);
  788. }
  789. return {};
  790. } catch (error) {
  791. console.warn('解析配置数据失败:', error);
  792. return {};
  793. }
  794. })()
  795. }
  796. },
  797. onLoad() {
  798. // Fetch user data when component loads
  799. this.fetchUserData();
  800. console.log(this.configData)
  801. },
  802. watch: {
  803. // 监听步骤显示状态的变化
  804. shouldShowWorkStep(newVal) {
  805. console.log('工作经历显示状态变化:', newVal);
  806. if (!newVal && this.currentStep === 8) {
  807. // 如果工作经历不需要显示且当前在工作经历页面,跳转到最后一个可见步骤
  808. this.$nextTick(() => {
  809. this.jumpToLastVisibleStep();
  810. });
  811. }
  812. },
  813. shouldShowSkillsStep(newVal) {
  814. console.log('专业技能显示状态变化:', newVal);
  815. },
  816. shouldShowEducationStep(newVal) {
  817. console.log('教育经历显示状态变化:', newVal);
  818. },
  819. shouldShowFamilyStep(newVal) {
  820. console.log('家庭成员显示状态变化:', newVal);
  821. }
  822. },
  823. computed: {
  824. // 添加计算属性来控制按钮显示
  825. showPrevButton() {
  826. return this.currentStep !== 1;
  827. },
  828. showNextButton() {
  829. const currentIndex = this.currentStepIndex;
  830. if (currentIndex === -1) return false;
  831. for (let i = currentIndex + 1; i < this.steps.length; i++) {
  832. const nextStepId = this.steps[i].id;
  833. let shouldShowNextStep = true;
  834. switch (nextStepId) {
  835. case 3:
  836. shouldShowNextStep = this.shouldShowFamilyStep;
  837. break;
  838. case 5:
  839. shouldShowNextStep = this.shouldShowEducationStep;
  840. break;
  841. case 6:
  842. shouldShowNextStep = this.shouldShowSkillsStep;
  843. break;
  844. case 8:
  845. shouldShowNextStep = this.shouldShowWorkStep;
  846. break;
  847. default:
  848. shouldShowNextStep = true;
  849. }
  850. if (shouldShowNextStep) return true;
  851. }
  852. return false;
  853. },
  854. showSubmitButton() {
  855. // 找到所有需要显示的步骤中的最后一个
  856. let lastVisibleStepId = null;
  857. for (let i = this.steps.length - 1; i >= 0; i--) {
  858. const stepId = this.steps[i].id;
  859. let shouldShowStep = false;
  860. switch (stepId) {
  861. case 3: // 家庭成员
  862. shouldShowStep = this.shouldShowFamilyStep;
  863. break;
  864. case 5: // 教育经历
  865. shouldShowStep = this.shouldShowEducationStep;
  866. break;
  867. case 6: // 专业技能
  868. shouldShowStep = this.shouldShowSkillsStep;
  869. break;
  870. case 8: // 工作经历
  871. shouldShowStep = this.shouldShowWorkStep;
  872. break;
  873. default:
  874. // 非特殊步骤默认显示
  875. shouldShowStep = true;
  876. }
  877. if (shouldShowStep) {
  878. lastVisibleStepId = stepId;
  879. break;
  880. }
  881. }
  882. // 调试信息
  883. console.log('当前步骤:', this.currentStep);
  884. console.log('最后一个可见步骤:', lastVisibleStepId);
  885. console.log('家庭成员显示:', this.shouldShowFamilyStep);
  886. console.log('教育经历显示:', this.shouldShowEducationStep);
  887. console.log('专业技能显示:', this.shouldShowSkillsStep);
  888. console.log('工作经历显示:', this.shouldShowWorkStep);
  889. console.log('是否显示提交按钮:', this.currentStep === lastVisibleStepId);
  890. // 如果当前步骤是最后一个需要显示的步骤,显示提交按钮
  891. return this.currentStep === lastVisibleStepId;
  892. },
  893. // 获取当前步骤在数组中的索引
  894. currentStepIndex() {
  895. return this.steps.findIndex(step => step.id === this.currentStep);
  896. },
  897. // 添加安全的配置访问器
  898. safeConfigData() {
  899. return this.configData || {};
  900. },
  901. safeProfileFieldsConfig() {
  902. return this.safeConfigData.profile_fields_config || {};
  903. },
  904. safeFamilyFieldsConfig() {
  905. return this.safeConfigData.family_fields_config || {};
  906. },
  907. safeEducationFieldsConfig() {
  908. return this.safeConfigData.education_fields_config || {};
  909. },
  910. safeWorkFieldsConfig() {
  911. return this.safeConfigData.work_experience_fields_config || {};
  912. },
  913. // 字段显示控制方法
  914. showNameField() {
  915. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.name?.visible !== false;
  916. },
  917. showGenderField() {
  918. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.gender?.visible !== false;
  919. },
  920. showPhoneField() {
  921. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.phone?.visible !== false;
  922. },
  923. showIdCardField() {
  924. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.id_card?.visible !== false;
  925. },
  926. showEthnicField() {
  927. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.ethnicity?.visible !== false;
  928. },
  929. showHeightField() {
  930. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.height?.visible !== false;
  931. },
  932. showWeightField() {
  933. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.weight?.visible !== false;
  934. },
  935. showCurrentAddress(){
  936. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.current_address?.visible !== false;
  937. },
  938. showResidence(){
  939. return Object.keys(this.safeProfileFieldsConfig).length === 0 || this.safeProfileFieldsConfig.household_location?.visible !== false;
  940. },
  941. showMarriageIndex(){
  942. return this.safeProfileFieldsConfig.marital_status?.visible !== false;
  943. },
  944. showExpectedSalary(){
  945. return this.safeProfileFieldsConfig.expected_salary?.visible !== false;
  946. },
  947. // 家庭成员字段显示控制
  948. showFamilyRelationField() {
  949. return Object.keys(this.safeFamilyFieldsConfig).length === 0 || this.safeFamilyFieldsConfig.relation?.visible !== false;
  950. },
  951. showFamilyNameField() {
  952. return Object.keys(this.safeFamilyFieldsConfig).length === 0 || this.safeFamilyFieldsConfig.name?.visible !== false;
  953. },
  954. showFamilyWorkplaceField() {
  955. return Object.keys(this.safeFamilyFieldsConfig).length === 0 || this.safeFamilyFieldsConfig.workplace?.visible !== false;
  956. },
  957. showFamilyPositionField() {
  958. return Object.keys(this.safeFamilyFieldsConfig).length === 0 || this.safeFamilyFieldsConfig.position?.visible !== false;
  959. },
  960. showFamilyPhoneField() {
  961. return Object.keys(this.safeFamilyFieldsConfig).length === 0 || this.safeFamilyFieldsConfig.phone?.visible !== false;
  962. },
  963. showFamilyisEmergency(){
  964. // this.safeFamilyFieldsConfig.family_contact_person?.visible !== false;
  965. return Object.keys(this.safeFamilyFieldsConfig).length === 0 || this.safeFamilyFieldsConfig.family_contact_person?.visible !== false;
  966. },
  967. // 教育经历字段显示控制
  968. showEducationTimeField() {
  969. return Object.keys(this.safeEducationFieldsConfig).length === 0 || (this.safeEducationFieldsConfig.start_date?.visible !== false && this.safeEducationFieldsConfig.end_date?.visible !== false);
  970. },
  971. showEducationSchoolField() {
  972. return Object.keys(this.safeEducationFieldsConfig).length === 0 || this.safeEducationFieldsConfig.school_name?.visible !== false;
  973. },
  974. showEducationMajorField() {
  975. return Object.keys(this.safeEducationFieldsConfig).length === 0 || this.safeEducationFieldsConfig.major?.visible !== false;
  976. },
  977. showEducationDegreeField() {
  978. return Object.keys(this.safeEducationFieldsConfig).length === 0 || this.safeEducationFieldsConfig.degree?.visible !== false;
  979. },
  980. // 工作经历字段显示控制
  981. showWorkTimeField() {
  982. return Object.keys(this.safeWorkFieldsConfig).length === 0 || (this.safeWorkFieldsConfig.start_date?.visible !== false && this.safeWorkFieldsConfig.end_date?.visible !== false);
  983. },
  984. showWorkCompanyField() {
  985. return Object.keys(this.safeWorkFieldsConfig).length === 0 || this.safeWorkFieldsConfig.company_name?.visible !== false;
  986. },
  987. showWorkDepartmentField() {
  988. return Object.keys(this.safeWorkFieldsConfig).length === 0 || this.safeWorkFieldsConfig.department?.visible !== false;
  989. },
  990. showWorkEmployeeCountField() {
  991. return Object.keys(this.safeWorkFieldsConfig).length === 0 || this.safeWorkFieldsConfig.company_size?.visible !== false;
  992. },
  993. showWorkPositionField() {
  994. return Object.keys(this.safeWorkFieldsConfig).length === 0 || this.safeWorkFieldsConfig.position?.visible !== false;
  995. },
  996. showWorkMonthlySalary(){
  997. return this.safeWorkFieldsConfig.monthly_salary?.visible
  998. },
  999. showWorkSupervisor(){
  1000. return this.safeWorkFieldsConfig.direct_supervisor?.visible
  1001. },
  1002. showWorkSupervisorPhone(){
  1003. return this.safeWorkFieldsConfig.supervisor_phone?.visible
  1004. },
  1005. showRequireProfessionalSkillsField() { //受培训
  1006. console.log(this.safeConfigData.require_professional_skills)
  1007. const value = this.safeConfigData.require_professional_skills
  1008. return value === undefined || value === null ? true : value
  1009. },
  1010. showRequireTrainingInfoField() { //专业技能
  1011. console.log(this.safeConfigData.require_training_info)
  1012. const value = this.safeConfigData.require_training_info
  1013. return value === undefined || value === null ? true : value
  1014. },
  1015. shouldShowSkillsStep() {
  1016. return this.showRequireTrainingInfoField || this.showRequireProfessionalSkillsField;
  1017. },
  1018. // 判断是否显示教育经历步骤
  1019. shouldShowEducationStep() {
  1020. // 如果没有配置数据,默认显示
  1021. if (Object.keys(this.safeEducationFieldsConfig).length === 0) {
  1022. return true;
  1023. }
  1024. // 检查所有教育经历字段是否都被隐藏
  1025. const fields = ['start_date', 'end_date', 'school_name', 'major', 'degree'];
  1026. return fields.some(field => this.safeEducationFieldsConfig[field]?.visible !== false);
  1027. },
  1028. // 判断是否显示家庭成员步骤
  1029. shouldShowFamilyStep() {
  1030. // 如果没有配置数据,默认显示
  1031. if (Object.keys(this.safeFamilyFieldsConfig).length === 0) {
  1032. return true;
  1033. }
  1034. // 检查所有家庭成员字段是否都被隐藏
  1035. const fields = ['relation', 'name', 'workplace', 'position', 'phone'];
  1036. return fields.some(field => this.safeFamilyFieldsConfig[field]?.visible !== false);
  1037. },
  1038. // 判断是否显示工作经历
  1039. shouldShowWorkStep() {
  1040. // 如果没有配置数据,默认显示
  1041. if (Object.keys(this.safeWorkFieldsConfig).length === 0) {
  1042. return true;
  1043. }
  1044. // 检查所有家庭成员字段是否都被隐藏
  1045. const fields = ['start_date', 'end_date', 'company_name', 'department', 'company_size','position','monthly_salary','direct_supervisor','supervisor_phone'];
  1046. return fields.some(field => this.safeWorkFieldsConfig[field]?.visible !== false);
  1047. },
  1048. },
  1049. methods: {
  1050. // 确保当前步骤是有效的(如果需要显示的话)
  1051. ensureValidStep() {
  1052. const currentStepId = this.currentStep;
  1053. let shouldShowCurrentStep = true;
  1054. // 检查当前步骤是否需要显示
  1055. switch (currentStepId) {
  1056. case 3: // 家庭成员
  1057. shouldShowCurrentStep = this.shouldShowFamilyStep;
  1058. break;
  1059. case 5: // 教育经历
  1060. shouldShowCurrentStep = this.shouldShowEducationStep;
  1061. break;
  1062. case 6: // 专业技能
  1063. shouldShowCurrentStep = this.shouldShowSkillsStep;
  1064. break;
  1065. case 8: // 工作经历
  1066. shouldShowCurrentStep = this.shouldShowWorkStep;
  1067. break;
  1068. default:
  1069. // 非特殊步骤默认显示
  1070. shouldShowCurrentStep = true;
  1071. }
  1072. // 如果当前步骤不需要显示,跳转到最后一个可见步骤
  1073. if (!shouldShowCurrentStep) {
  1074. this.jumpToLastVisibleStep();
  1075. }
  1076. },
  1077. // 跳转到最后一个可见步骤
  1078. jumpToLastVisibleStep() {
  1079. let lastVisibleStepId = null;
  1080. // 从后往前查找最后一个需要显示的步骤
  1081. for (let i = this.steps.length - 1; i >= 0; i--) {
  1082. const stepId = this.steps[i].id;
  1083. let shouldShowStep = false;
  1084. switch (stepId) {
  1085. case 3: // 家庭成员
  1086. shouldShowStep = this.shouldShowFamilyStep;
  1087. break;
  1088. case 5: // 教育经历
  1089. shouldShowStep = this.shouldShowEducationStep;
  1090. break;
  1091. case 6: // 专业技能
  1092. shouldShowStep = this.shouldShowSkillsStep;
  1093. break;
  1094. case 8: // 工作经历
  1095. shouldShowStep = this.shouldShowWorkStep;
  1096. break;
  1097. default:
  1098. // 非特殊步骤默认显示
  1099. shouldShowStep = true;
  1100. }
  1101. if (shouldShowStep) {
  1102. lastVisibleStepId = stepId;
  1103. break;
  1104. }
  1105. }
  1106. // 跳转到最后一个可见步骤
  1107. if (lastVisibleStepId) {
  1108. console.log('跳转到最后一个可见步骤:', lastVisibleStepId);
  1109. this.currentStep = lastVisibleStepId;
  1110. // 滚动到页面顶部
  1111. uni.pageScrollTo({
  1112. scrollTop: 0,
  1113. duration: 300
  1114. });
  1115. }
  1116. },
  1117. // 输入时限制小数位数
  1118. handleInput(event, field, maxDecimals) {
  1119. let value = event.detail.value;
  1120. // 1. 过滤非法字符并限制小数位
  1121. value = value
  1122. .replace(/[^\d.-]/g, '')
  1123. .replace(/(\..*)\./g, '$1')
  1124. .replace(/(-\d*)-/g, '$1')
  1125. .replace(new RegExp(`^(-?\\d*\\.\\d{${maxDecimals}}).*$`), '$1');
  1126. // 2. 处理以小数点开头的情况
  1127. if (value.startsWith('.')) {
  1128. value = '0' + value;
  1129. }
  1130. // 3. 更新数据
  1131. this.formData[field] = value;
  1132. // 4. 强制同步输入框显示
  1133. this.$nextTick(() => {
  1134. event.target.value = value;
  1135. });
  1136. },
  1137. // 失焦时补全小数位
  1138. handleBlur(field, precision = 2) {
  1139. const val = this.formData[field];
  1140. if (val === '' || val === undefined || val === null) return;
  1141. const num = parseFloat(val);
  1142. if (!isNaN(num)) {
  1143. this.formData[field] = num.toFixed(precision);
  1144. } else {
  1145. this.formData[field] = '';
  1146. }
  1147. },
  1148. // 添加承诺书相关方法
  1149. togglePromiseChecked() {
  1150. this.promiseChecked = !this.promiseChecked;
  1151. },
  1152. confirmPromise() {
  1153. if (this.promiseChecked) {
  1154. this.showPromiseModal = false;
  1155. } else {
  1156. uni.showToast({
  1157. title: '请先阅读并同意承诺书内容',
  1158. icon: 'none'
  1159. });
  1160. }
  1161. },
  1162. // 添加字段是否需要验证的判断方法
  1163. shouldValidateField(fieldName, section) {
  1164. section = section || 'profile';
  1165. switch (section) {
  1166. case 'profile':
  1167. const fieldShowMap = {
  1168. 'name': this.showNameField,
  1169. 'gender': this.showGenderField,
  1170. 'phone': this.showPhoneField,
  1171. 'idCard': this.showIdCardField,
  1172. 'ethnic': this.showEthnicField,
  1173. 'height': this.showHeightField,
  1174. 'weight': this.showWeightField,
  1175. 'currentAddress': this.showCurrentAddress, // 现居住地址总是显示和必填
  1176. 'expectedSalary': this.showExpectedSalary, // 期望薪资总是显示
  1177. 'skills': this.showRequireTrainingInfoField, // 专业技能根据配置显示和必填
  1178. 'training': this.showRequireProfessionalSkillsField, // 培训经历根据配置显示和必填
  1179. 'threePeriod': this.formData.gender === '女' // 只有女性时才需要验证三期状态
  1180. };
  1181. return fieldShowMap[fieldName] !== false;
  1182. case 'family':
  1183. const familyFieldShowMap = {
  1184. 'relation': this.showFamilyRelationField,
  1185. 'name': this.showFamilyNameField,
  1186. 'phone': this.showFamilyPhoneField,
  1187. 'workplaceOrAddress': this.showFamilyWorkplaceField,
  1188. 'position': this.showFamilyPositionField,
  1189. 'isEmergencyContact':this.showFamilyisEmergency
  1190. };
  1191. return familyFieldShowMap[fieldName] !== false;
  1192. case 'education':
  1193. const educationFieldShowMap = {
  1194. 'startTime': this.showEducationTimeField,
  1195. 'endTime': this.showEducationTimeField,
  1196. 'schoolName': this.showEducationSchoolField,
  1197. 'major': this.showEducationMajorField,
  1198. 'degree': this.showEducationDegreeField
  1199. };
  1200. return educationFieldShowMap[fieldName] !== false;
  1201. case 'work':
  1202. const workFieldShowMap = {
  1203. 'startTime': this.showWorkTimeField,
  1204. 'endTime': this.showWorkTimeField,
  1205. 'companyName': this.showWorkCompanyField,
  1206. 'department': this.showWorkDepartmentField,
  1207. 'position': this.showWorkPositionField,
  1208. 'employeeCount': this.showWorkEmployeeCountField,
  1209. 'monthlySalary': this.showWorkMonthlySalary, // 月薪总是需要验证
  1210. 'supervisor': this.showWorkSupervisor, // 直接领导总是需要验证
  1211. 'supervisorPhone': this.showWorkSupervisorPhone // 领导电话总是需要验证
  1212. };
  1213. return workFieldShowMap[fieldName] !== false;
  1214. default:
  1215. return true;
  1216. }
  1217. },
  1218. bindGenderChange(e) {
  1219. this.genderIndex = e.detail.value;
  1220. this.formData.gender = this.genderOptions[this.genderIndex];
  1221. // 清除性别的错误提示
  1222. if (this.formErrors.gender) {
  1223. this.formErrors.gender = '';
  1224. }
  1225. // 如果性别从女变为男,清空三期选择
  1226. if (this.formData.gender !== '女') {
  1227. this.formData.threePeriod = '';
  1228. this.threePeriodIndex = -1;
  1229. this.formErrors.threePeriod = ''; // 清除三期状态的错误提示
  1230. }
  1231. },
  1232. bindThreePeriodChange(e) {
  1233. this.threePeriodIndex = e.detail.value;
  1234. this.formData.threePeriod = this.threePeriodOptions[this.threePeriodIndex];
  1235. // 清除三期状态的错误提示
  1236. if (this.formErrors.threePeriod) {
  1237. this.formErrors.threePeriod = '';
  1238. }
  1239. },
  1240. bindPoliticalChange(e) {
  1241. this.politicalIndex = e.detail.value;
  1242. this.formData.political = this.politicalOptions[this.politicalIndex];
  1243. },
  1244. bindEthnicChange(e) {
  1245. this.ethnicIndex = e.detail.value;
  1246. this.formData.ethnic = this.ethnicOptions[this.ethnicIndex];
  1247. // 清除民族的错误提示
  1248. if (this.formErrors.ethnic) {
  1249. this.formErrors.ethnic = '';
  1250. }
  1251. },
  1252. bindMarriageChange(e) {
  1253. this.marriageIndex = e.detail.value;
  1254. this.formData.marriage = this.marriageOptions[this.marriageIndex];
  1255. },
  1256. bindDateChange(e) {
  1257. this.formData.birthDate = e.detail.value;
  1258. },
  1259. saveFamilyMember() {
  1260. // 重置错误信息
  1261. this.resetFamilyMemberErrors();
  1262. // 验证必填字段
  1263. let isValid = true;
  1264. // 只验证显示的字段
  1265. if (this.shouldValidateField('relation', 'family') && !this.familyMemberForm.relation) {
  1266. this.familyMemberErrors.relation = '请输入称谓';
  1267. isValid = false;
  1268. }
  1269. if (this.shouldValidateField('name', 'family') && !this.familyMemberForm.name) {
  1270. this.familyMemberErrors.name = '请输入姓名';
  1271. isValid = false;
  1272. }
  1273. // if (this.shouldValidateField('workplaceOrAddress', 'family') && !this.familyMemberForm.workplaceOrAddress) {
  1274. // this.familyMemberErrors.workplaceOrAddress = '请输入工作单位/家庭地址';
  1275. // isValid = false;
  1276. // }
  1277. // if (this.shouldValidateField('position', 'family') && !this.familyMemberForm.position) {
  1278. // this.familyMemberErrors.position = '请输入职务';
  1279. // isValid = false;
  1280. // }
  1281. // if (this.shouldValidateField('phone', 'family') && !this.familyMemberForm.phone) {
  1282. // this.familyMemberErrors.phone = '请输入联系电话';
  1283. // isValid = false;
  1284. // } else
  1285. if (this.shouldValidateField('phone', 'family') && this.familyMemberForm.phone && !/^1[3-9]\d{9}$/.test(this.familyMemberForm.phone)) {
  1286. this.familyMemberErrors.phone = '请输入正确的手机号';
  1287. isValid = false;
  1288. }
  1289. if (!isValid) {
  1290. uni.showToast({
  1291. title: '请完善家庭成员信息',
  1292. icon: 'none'
  1293. });
  1294. return;
  1295. }
  1296. // 原有的保存逻辑
  1297. if (this.isEditing) {
  1298. this.familyMembers[this.editingIndex] = {...this.familyMemberForm};
  1299. uni.showToast({
  1300. title: '修改成功',
  1301. icon: 'success'
  1302. });
  1303. this.isEditing = false;
  1304. this.editingIndex = -1;
  1305. } else {
  1306. this.familyMembers.push({...this.familyMemberForm});
  1307. uni.showToast({
  1308. title: '添加成功',
  1309. icon: 'success'
  1310. });
  1311. }
  1312. // 重置表单和错误信息
  1313. this.resetFamilyMemberForm();
  1314. },
  1315. // 添加重置错误信息的方法
  1316. resetFamilyMemberErrors() {
  1317. this.familyMemberErrors = {
  1318. relation: '',
  1319. name: '',
  1320. phone: '',
  1321. workplaceOrAddress: '',
  1322. position: ''
  1323. };
  1324. },
  1325. // 修改重置表单的方法
  1326. resetFamilyMemberForm() {
  1327. this.familyMemberForm = {
  1328. relation: '',
  1329. name: '',
  1330. workplaceOrAddress: '',
  1331. position: '',
  1332. phone: '',
  1333. isEmergencyContact: false
  1334. };
  1335. this.resetFamilyMemberErrors();
  1336. },
  1337. editFamilyMember(index) {
  1338. this.isEditing = true;
  1339. this.editingIndex = index;
  1340. this.familyMemberForm = {...this.familyMembers[index]};
  1341. uni.pageScrollTo({
  1342. selector: '.family-member-form',
  1343. duration: 300
  1344. });
  1345. },
  1346. cancelEdit() {
  1347. this.isEditing = false;
  1348. this.editingIndex = -1;
  1349. this.familyMemberForm = {
  1350. relation: '',
  1351. name: '',
  1352. workplaceOrAddress: '',
  1353. position: '',
  1354. phone: '',
  1355. isEmergencyContact: false
  1356. };
  1357. },
  1358. deleteFamilyMember(index) {
  1359. if (this.isEditing && this.editingIndex === index) {
  1360. this.cancelEdit();
  1361. }
  1362. this.familyMembers.splice(index, 1);
  1363. uni.showToast({
  1364. title: '已删除',
  1365. icon: 'none'
  1366. });
  1367. },
  1368. // 选择应聘来源类型
  1369. selectSourceType(type) {
  1370. this.formData.sourceType = type;
  1371. if (type === 'social') {
  1372. // 默认选择第一个社招来源
  1373. this.formData.socialSource = 'BOSS';
  1374. } else {
  1375. // 清空社招来源
  1376. this.formData.socialSource = '';
  1377. }
  1378. },
  1379. // 选择社招来源
  1380. selectSocialSource(source) {
  1381. this.formData.sourceType = 'social';
  1382. this.formData.socialSource = source;
  1383. },
  1384. // 教育经历相关方法
  1385. bindStartTimeChange(e) {
  1386. const startTime = e.detail.value;
  1387. if (this.educationForm.endTime && startTime > this.educationForm.endTime) {
  1388. uni.showToast({
  1389. title: '开始时间不能大于结束时间',
  1390. icon: 'none'
  1391. });
  1392. return;
  1393. }
  1394. this.educationForm.startTime = startTime;
  1395. this.educationErrors.startTime = false;
  1396. },
  1397. bindEndTimeChange(e) {
  1398. const endTime = e.detail.value;
  1399. if (this.educationForm.startTime && endTime < this.educationForm.startTime) {
  1400. uni.showToast({
  1401. title: '结束时间不能小于开始时间',
  1402. icon: 'none'
  1403. });
  1404. return;
  1405. }
  1406. this.educationForm.endTime = endTime;
  1407. this.educationErrors.endTime = false;
  1408. },
  1409. bindDegreeChange(e) {
  1410. this.degreeIndex = e.detail.value;
  1411. this.educationForm.degree = this.degreeOptions[this.degreeIndex];
  1412. },
  1413. saveEducation() {
  1414. // 重置错误信息
  1415. this.resetEducationErrors();
  1416. // 验证必填字段
  1417. let isValid = true;
  1418. // 只验证显示的字段
  1419. if (this.shouldValidateField('startTime', 'education') && !this.educationForm.startTime) {
  1420. this.educationErrors.startTime = '请选择开始时间';
  1421. isValid = false;
  1422. }
  1423. if (this.shouldValidateField('endTime', 'education') && !this.educationForm.endTime) {
  1424. this.educationErrors.endTime = '请选择结束时间';
  1425. isValid = false;
  1426. }
  1427. if (this.shouldValidateField('schoolName', 'education') && !this.educationForm.schoolName) {
  1428. this.educationErrors.schoolName = '请输入学校名称';
  1429. isValid = false;
  1430. }
  1431. if (this.shouldValidateField('major', 'education') && !this.educationForm.major) {
  1432. this.educationErrors.major = '请输入专业';
  1433. isValid = false;
  1434. }
  1435. if (this.shouldValidateField('degree', 'education') && !this.educationForm.degree) {
  1436. this.educationErrors.degree = '请选择学历';
  1437. isValid = false;
  1438. }
  1439. if (!isValid) {
  1440. uni.showToast({
  1441. title: '请完善教育经历信息',
  1442. icon: 'none'
  1443. });
  1444. return;
  1445. }
  1446. // 验证通过后的保存逻辑
  1447. if (this.isEditingEducation) {
  1448. this.educationList[this.editingEducationIndex] = {...this.educationForm};
  1449. uni.showToast({
  1450. title: '修改成功',
  1451. icon: 'success'
  1452. });
  1453. this.isEditingEducation = false;
  1454. this.editingEducationIndex = -1;
  1455. } else {
  1456. this.educationList.push({...this.educationForm});
  1457. uni.showToast({
  1458. title: '添加成功',
  1459. icon: 'success'
  1460. });
  1461. }
  1462. // 重置表单
  1463. this.educationForm = {
  1464. startTime: '',
  1465. endTime: '',
  1466. schoolName: '',
  1467. major: '',
  1468. degree: ''
  1469. };
  1470. this.degreeIndex = -1;
  1471. },
  1472. editEducation(index) {
  1473. this.isEditingEducation = true;
  1474. this.editingEducationIndex = index;
  1475. this.educationForm = {...this.educationList[index]};
  1476. // 设置学历索引
  1477. this.degreeIndex = this.degreeOptions.findIndex(item => item === this.educationForm.degree);
  1478. uni.pageScrollTo({
  1479. selector: '.education-form',
  1480. duration: 300
  1481. });
  1482. },
  1483. cancelEditEducation() {
  1484. this.isEditingEducation = false;
  1485. this.editingEducationIndex = -1;
  1486. this.educationForm = {
  1487. startTime: '',
  1488. endTime: '',
  1489. schoolName: '',
  1490. major: '',
  1491. degree: ''
  1492. };
  1493. this.degreeIndex = -1;
  1494. },
  1495. deleteEducation(index) {
  1496. if (this.isEditingEducation && this.editingEducationIndex === index) {
  1497. this.cancelEditEducation();
  1498. }
  1499. this.educationList.splice(index, 1);
  1500. uni.showToast({
  1501. title: '已删除',
  1502. icon: 'none'
  1503. });
  1504. },
  1505. // 工作经历相关方法
  1506. bindWorkStartTimeChange(e) {
  1507. const startTime = e.detail.value;
  1508. if (this.workForm.endTime && startTime > this.workForm.endTime) {
  1509. uni.showToast({
  1510. title: '开始时间不能大于结束时间',
  1511. icon: 'none'
  1512. });
  1513. return;
  1514. }
  1515. this.workForm.startTime = startTime;
  1516. this.workErrors.startTime = false;
  1517. },
  1518. bindWorkEndTimeChange(e) {
  1519. const endTime = e.detail.value;
  1520. if (this.workForm.startTime && endTime < this.workForm.startTime) {
  1521. uni.showToast({
  1522. title: '结束时间不能小于开始时间',
  1523. icon: 'none'
  1524. });
  1525. return;
  1526. }
  1527. this.workForm.endTime = endTime;
  1528. this.workErrors.endTime = false;
  1529. },
  1530. saveWork() {
  1531. // 重置所有工作经历相关的错误信息
  1532. this.workErrors = {
  1533. startTime: '',
  1534. endTime: '',
  1535. companyName: '',
  1536. department: '',
  1537. position: '',
  1538. employeeCount: '',
  1539. monthlySalary: '',
  1540. supervisor: '',
  1541. supervisorPhone: ''
  1542. };
  1543. // 验证必填字段
  1544. let isValid = true;
  1545. // 只验证显示的字段
  1546. if (this.shouldValidateField('startTime', 'work') && !this.workForm.startTime) {
  1547. this.workErrors.startTime = '请选择开始时间';
  1548. isValid = false;
  1549. }
  1550. if (this.shouldValidateField('endTime', 'work') && !this.workForm.endTime) {
  1551. this.workErrors.endTime = '请选择结束时间';
  1552. isValid = false;
  1553. }
  1554. if (this.shouldValidateField('companyName', 'work') && !this.workForm.companyName) {
  1555. this.workErrors.companyName = '请输入单位名称';
  1556. isValid = false;
  1557. }
  1558. if (this.shouldValidateField('department', 'work') && !this.workForm.department) {
  1559. this.workErrors.department = '请输入任职部门';
  1560. isValid = false;
  1561. }
  1562. if (this.shouldValidateField('position', 'work') && !this.workForm.position) {
  1563. this.workErrors.position = '请输入担任职务';
  1564. isValid = false;
  1565. }
  1566. if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
  1567. this.workErrors.employeeCount = '请输入单位人数';
  1568. isValid = false;
  1569. }
  1570. if (this.shouldValidateField('monthlySalary', 'work') && !this.workForm.monthlySalary) {
  1571. this.workErrors.monthlySalary = '请输入月总收入';
  1572. isValid = false;
  1573. }
  1574. // if (this.shouldValidateField('supervisor', 'work') && !this.workForm.supervisor) {
  1575. // this.workErrors.supervisor = '请输入直属上级';
  1576. // isValid = false;
  1577. // }
  1578. // if (this.shouldValidateField('supervisorPhone', 'work') && !this.workForm.supervisorPhone) {
  1579. // this.workErrors.supervisorPhone = '请输入直属上级电话';
  1580. // isValid = false;
  1581. // }
  1582. // 如果验证不通过,直接返回
  1583. if (!isValid) {
  1584. uni.showToast({
  1585. title: '请完善工作经历信息',
  1586. icon: 'none'
  1587. });
  1588. return;
  1589. }
  1590. // 验证通过后的保存逻辑
  1591. if (this.isEditingWork) {
  1592. this.workList[this.editingWorkIndex] = {...this.workForm};
  1593. uni.showToast({
  1594. title: '修改成功',
  1595. icon: 'success'
  1596. });
  1597. this.isEditingWork = false;
  1598. this.editingWorkIndex = -1;
  1599. } else {
  1600. this.workList.push({...this.workForm});
  1601. uni.showToast({
  1602. title: '添加成功',
  1603. icon: 'success'
  1604. });
  1605. }
  1606. // 重置表单
  1607. this.workForm = {
  1608. startTime: '',
  1609. endTime: '',
  1610. companyName: '',
  1611. department: '',
  1612. employeeCount: '',
  1613. position: '',
  1614. monthlySalary: '',
  1615. supervisor: '',
  1616. supervisorPhone: ''
  1617. };
  1618. },
  1619. editWork(index) {
  1620. this.isEditingWork = true;
  1621. this.editingWorkIndex = index;
  1622. this.workForm = {...this.workList[index]};
  1623. uni.pageScrollTo({
  1624. selector: '.work-form',
  1625. duration: 300
  1626. });
  1627. },
  1628. cancelEditWork() {
  1629. this.isEditingWork = false;
  1630. this.editingWorkIndex = -1;
  1631. this.workForm = {
  1632. startTime: '',
  1633. endTime: '',
  1634. companyName: '',
  1635. department: '',
  1636. employeeCount: '',
  1637. position: '',
  1638. monthlySalary: '',
  1639. supervisor: '',
  1640. supervisorPhone: ''
  1641. };
  1642. },
  1643. deleteWork(index) {
  1644. if (this.isEditingWork && this.editingWorkIndex === index) {
  1645. this.cancelEditWork();
  1646. }
  1647. this.workList.splice(index, 1);
  1648. uni.showToast({
  1649. title: '已删除',
  1650. icon: 'none'
  1651. });
  1652. },
  1653. submitForm() {
  1654. // 先验证当前步骤
  1655. if (!this.validateCurrentStep()) {
  1656. return;
  1657. }
  1658. // 在提交前检查并自动保存所有未保存的表单
  1659. this.autoSaveAllUnsavedForms();
  1660. // 验证所有必填字段
  1661. const allRequired = [
  1662. 'name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress'
  1663. ];
  1664. let isValid = true;
  1665. allRequired.forEach(field => {
  1666. // 只验证显示的字段
  1667. if (this.shouldValidateField(field) && !this.validateField(field, this.formData[field])) {
  1668. isValid = false;
  1669. }
  1670. });
  1671. // 验证专业技能和培训
  1672. if (this.shouldValidateField('skills') && !this.formData.skills?.trim()) {
  1673. this.formErrors.skills = '请描述您的专业技能';
  1674. isValid = false;
  1675. }
  1676. if (this.shouldValidateField('training') && !this.formData.training?.trim()) {
  1677. this.formErrors.training = '请描述您的培训经历';
  1678. isValid = false;
  1679. }
  1680. if (!isValid) {
  1681. uni.showToast({
  1682. title: '请完善所有必填信息',
  1683. icon: 'none'
  1684. });
  1685. return;
  1686. }
  1687. // 检查必要的用户信息
  1688. const userInfo = uni.getStorageSync('userInfo');
  1689. if (!userInfo) {
  1690. uni.showToast({
  1691. title: '用户信息获取失败,请重新登录',
  1692. icon: 'none',
  1693. duration: 2000
  1694. });
  1695. return;
  1696. }
  1697. try {
  1698. const userData = JSON.parse(userInfo);
  1699. const submitData = {
  1700. tenant_id: uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1,
  1701. user_id: userData.id,
  1702. personal_info: {
  1703. name: this.formData.name,
  1704. gender: this.formData.gender,
  1705. phone: this.formData.phone,
  1706. id_card: this.formData.idCard,
  1707. address: this.formData.currentAddress,
  1708. professional_skills: this.formData.skills ? this.formData.skills.split(',') : []
  1709. },
  1710. profile: {
  1711. female_status: this.getFemaleStatus(),
  1712. marital_status: this.getMaritalStatus(),
  1713. height: parseFloat(this.formData.height) || 0,
  1714. weight: parseFloat(this.formData.weight) || 0,
  1715. ethnicity: this.formData.ethnic,
  1716. current_address: this.formData.currentAddress,
  1717. expected_salary: parseFloat(this.formData.expectedSalary) || 0
  1718. },
  1719. educations: this.formatEducations(),
  1720. family_members: this.formatFamilyMembers(),
  1721. work_experiences: this.formatWorkExperiences()
  1722. };
  1723. // 数据检查
  1724. if (!submitData.personal_info.name || !submitData.personal_info.gender || !submitData.personal_info.phone) {
  1725. uni.showToast({
  1726. title: '基本信息不完整',
  1727. icon: 'none',
  1728. duration: 2000
  1729. });
  1730. return;
  1731. }
  1732. this.sendFormData(submitData);
  1733. } catch (error) {
  1734. console.error('数据处理错误:', error);
  1735. uni.showToast({
  1736. title: '数据处理错误,请重试',
  1737. icon: 'none',
  1738. duration: 2000
  1739. });
  1740. }
  1741. },
  1742. // 辅助方法:发送表单数据
  1743. sendFormData(submitData) {
  1744. uni.showLoading({ title: '提交中...' });
  1745. // 添加请求头和token
  1746. const token = uni.getStorageSync('token');
  1747. uni.request({
  1748. url: `${apiBaseUrl}/wechat/user/profile/update`,
  1749. method: 'POST',
  1750. data: submitData,
  1751. header: {
  1752. 'content-type': 'application/json',
  1753. 'Authorization': token ? `Bearer ${token}` : ''
  1754. },
  1755. success: (res) => {
  1756. uni.hideLoading();
  1757. if (res.statusCode === 200) {
  1758. if (res.data.code === 2000) {
  1759. uni.showToast({
  1760. title: '提交成功',
  1761. icon: 'success',
  1762. duration: 2000
  1763. });
  1764. uni.navigateTo({
  1765. url: '/pages/interview-notice/interview-notice'
  1766. });
  1767. } else {
  1768. uni.showToast({
  1769. title: res.data.msg || '提交失败',
  1770. icon: 'none',
  1771. duration: 2000
  1772. });
  1773. }
  1774. } else {
  1775. uni.showToast({
  1776. title: '服务器响应错误',
  1777. icon: 'none',
  1778. duration: 2000
  1779. });
  1780. }
  1781. },
  1782. fail: (err) => {
  1783. console.error('提交失败:', err);
  1784. uni.hideLoading();
  1785. // 检查具体错误类型
  1786. if (err.errMsg.includes('timeout')) {
  1787. uni.showToast({
  1788. title: '请求超时,请检查网络后重试',
  1789. icon: 'none',
  1790. duration: 2000
  1791. });
  1792. } else if (err.errMsg.includes('fail')) {
  1793. uni.showToast({
  1794. title: '网络连接失败,请检查网络设置',
  1795. icon: 'none',
  1796. duration: 2000
  1797. });
  1798. } else {
  1799. uni.showToast({
  1800. title: '提交失败,请稍后重试',
  1801. icon: 'none',
  1802. duration: 2000
  1803. });
  1804. }
  1805. },
  1806. complete: () => {
  1807. // 可以在这里添加完成后的处理逻辑
  1808. }
  1809. });
  1810. },
  1811. // 数据格式化方法
  1812. getFemaleStatus() {
  1813. if (this.formData.gender !== '女') return 0;
  1814. const statusMap = { '孕期': 1, '产期': 2, '哺乳期': 3 };
  1815. return statusMap[this.formData.threePeriod] || 0;
  1816. },
  1817. getMaritalStatus() {
  1818. const statusMap = { '未婚': 0, '已婚': 1, '离异': 2, '丧偶': 3 };
  1819. return statusMap[this.formData.marriage] || 0;
  1820. },
  1821. formatEducations() {
  1822. return this.educationList.map((edu, index) => ({
  1823. education_type: index === 0 ? 1 : 2,
  1824. degree: this.mapDegreeToNumber(edu.degree),
  1825. start_date: edu.startTime,
  1826. end_date: edu.endTime,
  1827. school_name: edu.schoolName,
  1828. major: edu.major
  1829. }));
  1830. },
  1831. formatFamilyMembers() {
  1832. return this.familyMembers.map(member => ({
  1833. relation: member.relation,
  1834. name: member.name,
  1835. workplace: member.workplaceOrAddress,
  1836. position: member.position,
  1837. phone: member.phone,
  1838. //is_emergency_contact: member.isEmergencyContact||false // 添加紧急联系人标识
  1839. }));
  1840. },
  1841. formatWorkExperiences() {
  1842. return this.workList.map(work => ({
  1843. start_date: work.startTime,
  1844. end_date: work.endTime,
  1845. company_name: work.companyName,
  1846. department: work.department,
  1847. company_size: parseInt(work.employeeCount)||0,
  1848. position: work.position,
  1849. monthly_salary: work.monthlySalary||0,
  1850. supervisor_name: work.supervisor,
  1851. supervisor_phone: work.supervisorPhone
  1852. }));
  1853. },
  1854. // 学历映射辅助方法
  1855. mapDegreeToNumber(degreeText) {
  1856. const degreeMap = {
  1857. '高中': 1,
  1858. '中专': 1,
  1859. '大专': 2,
  1860. '本科': 3,
  1861. '硕士': 4,
  1862. '博士': 5
  1863. };
  1864. return degreeMap[degreeText] || 6; // 默认为其他
  1865. },
  1866. prevStep() {
  1867. const prevIndex = this.currentStepIndex - 1;
  1868. if (prevIndex >= 0) {
  1869. let targetIndex = prevIndex;
  1870. // 检查上一步是否需要跳过
  1871. while (targetIndex >= 0) {
  1872. const stepId = this.steps[targetIndex].id;
  1873. // 如果是专业技能步骤且不需要显示,则跳过
  1874. if (stepId === 6 && !this.shouldShowSkillsStep) {
  1875. targetIndex--;
  1876. continue;
  1877. }
  1878. // 如果是教育经历步骤且不需要显示,则跳过
  1879. if (stepId === 5 && !this.shouldShowEducationStep) {
  1880. targetIndex--;
  1881. continue;
  1882. }
  1883. // 如果是家庭成员步骤且不需要显示,则跳过
  1884. if (stepId === 3 && !this.shouldShowFamilyStep) {
  1885. targetIndex--;
  1886. continue;
  1887. }
  1888. // 如果是工作经历步骤且不需要显示,则跳过
  1889. if (stepId === 8 && !this.shouldShowWorkStep) {
  1890. targetIndex--;
  1891. continue;
  1892. }
  1893. // 找到有效步骤,跳出循环
  1894. break;
  1895. }
  1896. // 如果找到有效步骤,跳转到该步骤
  1897. if (targetIndex >= 0) {
  1898. this.currentStep = this.steps[targetIndex].id;
  1899. }
  1900. // 滚动到页面顶部
  1901. uni.pageScrollTo({
  1902. scrollTop: 0,
  1903. duration: 300
  1904. });
  1905. }
  1906. },
  1907. nextStep() {
  1908. // 验证当前步骤
  1909. if (!this.validateCurrentStep()) {
  1910. return;
  1911. }
  1912. // 如果是第一步,需要进行身份验证
  1913. if (this.currentStep === 1) {
  1914. this.verifyIdentity();
  1915. return;
  1916. }
  1917. const nextIndex = this.currentStepIndex + 1;
  1918. if (nextIndex < this.steps.length) {
  1919. let targetIndex = nextIndex;
  1920. // 检查下一步是否需要跳过
  1921. while (targetIndex < this.steps.length) {
  1922. const stepId = this.steps[targetIndex].id;
  1923. console.log(this.steps[targetIndex].id)
  1924. // 如果是家庭成员步骤且不需要显示,则跳过
  1925. if (stepId === 3 && !this.shouldShowFamilyStep) {
  1926. targetIndex++;
  1927. continue;
  1928. }
  1929. // 如果是教育经历步骤且不需要显示,则跳过
  1930. if (stepId === 5 && !this.shouldShowEducationStep) {
  1931. targetIndex++;
  1932. continue;
  1933. }
  1934. // 如果是专业技能步骤且不需要显示,则跳过
  1935. if (stepId === 6 && !this.shouldShowSkillsStep) {
  1936. targetIndex++;
  1937. continue;
  1938. }
  1939. // 如果是工作经历步骤且不需要显示,则跳过
  1940. if (stepId === 8 && !this.shouldShowWorkStep) {
  1941. targetIndex++;
  1942. continue;
  1943. }
  1944. // 找到有效步骤,跳出循环
  1945. break;
  1946. }
  1947. // 如果找到有效步骤,跳转到该步骤
  1948. if (targetIndex < this.steps.length) {
  1949. this.currentStep = this.steps[targetIndex].id;
  1950. } else {
  1951. // 如果没有找到下一个有效步骤,说明当前步骤是最后一个需要显示的步骤
  1952. // 此时应该显示提交按钮,不需要跳转
  1953. console.log('当前步骤是最后一个需要显示的步骤,显示提交按钮');
  1954. }
  1955. // 滚动到页面顶部
  1956. uni.pageScrollTo({
  1957. scrollTop: 0,
  1958. duration: 300
  1959. });
  1960. }
  1961. },
  1962. // 身份验证方法
  1963. verifyIdentity() {
  1964. // 清空错误信息
  1965. this.formErrors = {
  1966. name: '',
  1967. idCard: '',
  1968. phone: ''
  1969. };
  1970. uni.showLoading({
  1971. title: '身份验证中...'
  1972. });
  1973. uni.request({
  1974. url: `${apiBaseUrl}/wechat/identity/verify`,
  1975. method: 'POST',
  1976. data: {
  1977. name: this.formData.name,
  1978. id_number: this.formData.idCard,
  1979. mobile: this.formData.phone
  1980. },
  1981. header: {
  1982. 'content-type': 'application/x-www-form-urlencoded'
  1983. },
  1984. success: (res) => {
  1985. uni.hideLoading();
  1986. console.log(res);
  1987. if (res.data.code === 200) {
  1988. // 验证通过,进入下一步
  1989. let targetIndex = this.currentStepIndex + 1;
  1990. // 跳过不需要显示的步骤(与 nextStep 保持一致)
  1991. while (targetIndex < this.steps.length) {
  1992. const stepId = this.steps[targetIndex].id;
  1993. if (stepId === 3 && !this.shouldShowFamilyStep) { targetIndex++; continue; }
  1994. if (stepId === 5 && !this.shouldShowEducationStep) { targetIndex++; continue; }
  1995. if (stepId === 6 && !this.shouldShowSkillsStep) { targetIndex++; continue; }
  1996. if (stepId === 8 && !this.shouldShowWorkStep) { targetIndex++; continue; }
  1997. break;
  1998. }
  1999. if (targetIndex < this.steps.length) {
  2000. this.currentStep = this.steps[targetIndex].id;
  2001. uni.pageScrollTo({ scrollTop: 0, duration: 300 });
  2002. } else {
  2003. // 如果没有找到下一个有效步骤,说明当前步骤是最后一个需要显示的步骤
  2004. // 此时应该显示提交按钮,不需要跳转
  2005. console.log('身份验证通过后,当前步骤是最后一个需要显示的步骤,显示提交按钮');
  2006. }
  2007. /* 保存姓名 */
  2008. this.setUserInfo(this.formData);
  2009. } else {
  2010. // 验证失败,显示错误信息
  2011. this.handleVerificationError(res.data);
  2012. }
  2013. },
  2014. fail: (err) => {
  2015. this.handleRequestError(err);
  2016. }
  2017. });
  2018. },
  2019. setUserInfo(data) {
  2020. uni.request({
  2021. url: `${apiBaseUrl}/wechat/updateUserInfo`,
  2022. method: 'POST',
  2023. data: {
  2024. openid: JSON.parse(uni.getStorageSync('userInfo')).openid,
  2025. name: data.name,
  2026. id_card: data.idCard,
  2027. purePhoneNumber: data.phone,
  2028. tenant_id:uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1,
  2029. examine:0
  2030. },
  2031. header: {
  2032. 'content-type': 'application/x-www-form-urlencoded'
  2033. },
  2034. success: (res) => {
  2035. console.log(res);
  2036. }
  2037. });
  2038. },
  2039. // 处理验证错误
  2040. handleVerificationError(data) {
  2041. this.formErrors.name = '姓名验证失败,请检查姓名是否正确';
  2042. this.formErrors.idCard = '身份证号验证失败,请检查身份证号是否正确';
  2043. this.formErrors.phone = '手机号验证失败,请检查手机号是否正确';
  2044. uni.showToast({
  2045. title: data.msg || '身份验证失败',
  2046. icon: 'none'
  2047. });
  2048. },
  2049. // 处理请求错误
  2050. handleRequestError(err) {
  2051. uni.hideLoading();
  2052. uni.showToast({
  2053. title: '网络错误,请检查网络连接',
  2054. icon: 'none',
  2055. duration: 2000
  2056. });
  2057. console.error('请求失败:', err);
  2058. },
  2059. // 验证当前步骤的必填项
  2060. validateCurrentStep() {
  2061. let isValid = true;
  2062. switch (this.currentStep) {
  2063. case 1: // 基本信息
  2064. const basicFields = ['name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress'];
  2065. basicFields.forEach(field => {
  2066. // 只验证显示的字段
  2067. if (this.shouldValidateField(field) && !this.validateField(field, this.formData[field])) {
  2068. isValid = false;
  2069. }
  2070. });
  2071. // 特殊验证:女性三期状态
  2072. if (this.shouldValidateField('threePeriod') && this.formData.gender === '女' && this.threePeriodIndex === -1) {
  2073. this.formErrors.threePeriod = '请选择三期状态';
  2074. isValid = false;
  2075. }
  2076. // 可选字段验证(如果有值则验证格式)
  2077. if (this.shouldValidateField('height') && this.formData.height) {
  2078. isValid = this.validateField('height', this.formData.height) && isValid;
  2079. }
  2080. if (this.shouldValidateField('weight') && this.formData.weight) {
  2081. isValid = this.validateField('weight', this.formData.weight) && isValid;
  2082. }
  2083. if (this.shouldValidateField('expectedSalary') && this.formData.expectedSalary) {
  2084. isValid = this.validateField('expectedSalary', this.formData.expectedSalary) && isValid;
  2085. }
  2086. break;
  2087. case 3: // 家庭成员
  2088. // 检查是否有未保存的家庭成员表单
  2089. if (this.hasUnsavedFamilyMemberForm()) {
  2090. // 尝试自动保存
  2091. if (!this.autoSaveFamilyMember()) {
  2092. isValid = false;
  2093. break;
  2094. }
  2095. }
  2096. console.log(this.familyMembers.length);
  2097. if (this.familyMembers.length == 0) {
  2098. uni.showToast({
  2099. title: '请至少添加一位家庭成员',
  2100. icon: 'none'
  2101. });
  2102. isValid = false;
  2103. }
  2104. break;
  2105. case 5: // 教育经历
  2106. // 检查是否有未保存的教育经历表单
  2107. if (this.hasUnsavedEducationForm()) {
  2108. // 尝试自动保存
  2109. if (!this.autoSaveEducation()) {
  2110. isValid = false;
  2111. break;
  2112. }
  2113. }
  2114. if (this.educationList.length === 0) {
  2115. uni.showToast({
  2116. title: '请至少添加一项教育经历',
  2117. icon: 'none'
  2118. });
  2119. isValid = false;
  2120. }
  2121. break;
  2122. case 6: // 专业技能
  2123. if (this.shouldValidateField('skills') && !this.formData.skills?.trim()) {
  2124. this.formErrors.skills = '请描述您的专业技能';
  2125. isValid = false;
  2126. }
  2127. if (this.shouldValidateField('training') && !this.formData.training?.trim()) {
  2128. this.formErrors.training = '请描述您的培训经历';
  2129. isValid = false;
  2130. }
  2131. break;
  2132. case 8: // 工作经历
  2133. // 检查是否有未保存的工作经历表单
  2134. if (this.hasUnsavedWorkForm()) {
  2135. // 尝试自动保存
  2136. if (!this.autoSaveWork()) {
  2137. isValid = false;
  2138. break;
  2139. }
  2140. }
  2141. if (this.workList.length === 0) {
  2142. uni.showToast({
  2143. title: '请至少添加一项工作经历',
  2144. icon: 'none'
  2145. });
  2146. isValid = false;
  2147. }
  2148. break;
  2149. }
  2150. /* if (!isValid) {
  2151. uni.showToast({
  2152. title: '请完善所有必填信息',
  2153. icon: 'none'
  2154. });
  2155. } */
  2156. return isValid;
  2157. },
  2158. // Add method to fetch user data
  2159. fetchUserData() {
  2160. this.isLoading = true;
  2161. // Get openid from storage
  2162. const userInfo = uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')) : {};
  2163. const openid = userInfo.openid;
  2164. if (!openid) {
  2165. uni.showToast({
  2166. title: '用户信息获取失败,请重新登录',
  2167. icon: 'none'
  2168. });
  2169. this.isLoading = false;
  2170. return;
  2171. }
  2172. uni.request({
  2173. url: `${apiBaseUrl}/api/wechat/user/get_full_info?tenant_id=${uni.getStorageSync('tenant_id') || JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1}&openid=${openid}`,
  2174. method: 'GET',
  2175. success: (res) => {
  2176. // 无论结果如何,都保持承诺书显示状态
  2177. this.showPromiseModal = true;
  2178. /* if (res.data.code === 2000) { */
  2179. // Successfully fetched data
  2180. this.populateFormData(res.data.data);
  2181. /* } else {
  2182. uni.showToast({
  2183. title: res.data.msg || '获取用户信息失败',
  2184. icon: 'none'
  2185. });
  2186. } */
  2187. },
  2188. fail: (err) => {
  2189. /* console.error('获取用户信息失败:', err);
  2190. uni.showToast({
  2191. title: '网络错误,请检查网络连接',
  2192. icon: 'none'
  2193. }); */
  2194. },
  2195. complete: () => {
  2196. this.isLoading = false;
  2197. // 数据加载完成后,检查当前步骤是否需要显示
  2198. this.$nextTick(() => {
  2199. this.ensureValidStep();
  2200. });
  2201. }
  2202. });
  2203. },
  2204. // Add method to populate form data with fetched data
  2205. populateFormData(data) {
  2206. const { user_info, profile, educations, work_experiences, family_members } = data;
  2207. // Populate basic user info
  2208. if (user_info) {
  2209. this.formData.name = user_info.name || '';
  2210. this.formData.gender = user_info.gender_text || '';
  2211. this.genderIndex = this.genderOptions.findIndex(item => item === this.formData.gender);
  2212. this.formData.idCard = user_info.id_card || '';
  2213. this.formData.phone = user_info.phone || '';
  2214. this.formData.email = user_info.email || '';
  2215. }
  2216. // Populate profile data
  2217. if (profile) {
  2218. // Set political status
  2219. this.formData.political = profile.political_status || '';
  2220. this.politicalIndex = this.politicalOptions.findIndex(item => item === this.formData.political);
  2221. // Set ethnic
  2222. this.formData.ethnic = profile.ethnicity || '';
  2223. this.ethnicIndex = this.ethnicOptions.findIndex(item => item === this.formData.ethnic);
  2224. // Set height and weight
  2225. this.formData.height = profile.height || '';
  2226. this.formData.weight = profile.weight || '';
  2227. // Set native place and residence
  2228. this.formData.nativePlace = profile.native_place || '';
  2229. this.formData.residence = profile.household_location || '';
  2230. // Set current address
  2231. this.formData.currentAddress = profile.current_address || '';
  2232. // Set marriage status
  2233. this.formData.marriage = profile.marital_status_text || '';
  2234. this.marriageIndex = this.marriageOptions.findIndex(item => item === this.formData.marriage);
  2235. // Set three period status for female
  2236. if (this.formData.gender === '女' && profile.female_status !== undefined) {
  2237. const femaleStatusMap = {0: '无', 1: '孕期', 2: '产期', 3: '哺乳期'};
  2238. this.formData.threePeriod = femaleStatusMap[profile.female_status] || '无';
  2239. this.threePeriodIndex = this.threePeriodOptions.findIndex(item => item === this.formData.threePeriod);
  2240. }
  2241. // Set expected salary
  2242. this.formData.expectedSalary = profile.expected_salary || '';
  2243. // Set emergency contact
  2244. this.formData.emergencyContact = profile.emergency_contact || '';
  2245. this.formData.emergencyPhone = profile.emergency_phone || '';
  2246. // Set hobby and motto
  2247. this.formData.hobby = profile.specialties || '';
  2248. this.formData.motto = profile.life_motto || '';
  2249. // Set recruitment source
  2250. const sourceTypeMap = {
  2251. 1: 'school',
  2252. 2: 'social',
  2253. 3: 'social',
  2254. 4: 'social',
  2255. 5: 'social'
  2256. };
  2257. const socialSourceMap = {
  2258. 2: 'BOSS',
  2259. 3: 'zhilian',
  2260. 4: 'liepin',
  2261. 5: 'other'
  2262. };
  2263. this.formData.sourceType = sourceTypeMap[profile.recruitment_source] || 'social';
  2264. if (this.formData.sourceType === 'social') {
  2265. this.formData.socialSource = socialSourceMap[profile.recruitment_source] || '';
  2266. if (this.formData.socialSource === 'other') {
  2267. this.formData.otherSocialSource = profile.recruitment_source_detail || '';
  2268. }
  2269. } else if (this.formData.sourceType === 'school') {
  2270. this.formData.otherSchoolSource = profile.recruitment_source_detail || '';
  2271. }
  2272. }
  2273. // Populate educations data
  2274. if (educations && educations.length > 0) {
  2275. this.educationList = educations.map(edu => {
  2276. const degreeMap = {
  2277. 1: '高中',
  2278. 2: '大专',
  2279. 3: '本科',
  2280. 4: '硕士',
  2281. 5: '博士'
  2282. };
  2283. return {
  2284. startTime: edu.start_date || '',
  2285. endTime: edu.end_date || '',
  2286. schoolName: edu.school_name || '',
  2287. major: edu.major || '',
  2288. degree: degreeMap[edu.degree] || ''
  2289. };
  2290. });
  2291. }
  2292. // Populate work experience data
  2293. if (work_experiences && work_experiences.length > 0) {
  2294. this.workList = work_experiences.map(work => {
  2295. return {
  2296. startTime: work.start_date || '',
  2297. endTime: work.end_date || '',
  2298. companyName: work.company_name || '',
  2299. department: work.department || '',
  2300. employeeCount: work.company_size || '',
  2301. position: work.position || '',
  2302. monthlySalary: work.monthly_salary || '',
  2303. supervisor: work.supervisor_name || '',
  2304. supervisorPhone: work.supervisor_phone || ''
  2305. };
  2306. });
  2307. }
  2308. // Populate family members data
  2309. if (family_members && family_members.length > 0) {
  2310. this.familyMembers = family_members.map(member => {
  2311. return {
  2312. relation: member.relation || '',
  2313. name: member.name || '',
  2314. workplaceOrAddress: member.workplace || '',
  2315. position: member.position || '',
  2316. phone: member.phone || '',
  2317. isEmergencyContact: member.isEmergencyContact || false
  2318. };
  2319. });
  2320. }
  2321. // 移除这段代码,确保承诺书始终显示
  2322. // if (user_info && user_info.is_profile_complete) {
  2323. // this.showPromiseModal = false;
  2324. // }
  2325. },
  2326. // 处理紧急联系人开关变化
  2327. handleEmergencyContactChange(e) {
  2328. this.familyMemberForm.isEmergencyContact = e.detail.value;
  2329. // 如果设置为紧急联系人,自动填充到紧急联系人字段
  2330. if (e.detail.value) {
  2331. this.formData.emergencyContact = this.familyMemberForm.name;
  2332. this.formData.emergencyPhone = this.familyMemberForm.phone;
  2333. }
  2334. },
  2335. // 添加重置教育经历错误信息的方法
  2336. resetEducationErrors() {
  2337. this.educationErrors = {
  2338. startTime: '',
  2339. endTime: '',
  2340. schoolName: '',
  2341. major: '',
  2342. degree: ''
  2343. };
  2344. },
  2345. // 添加通用验证方法
  2346. validateField(fieldName, value) {
  2347. const rule = this.validationRules[fieldName];
  2348. if (!rule) return true;
  2349. // 如果字段被隐藏,不进行验证
  2350. if (!this.shouldValidateField(fieldName)) {
  2351. return true;
  2352. }
  2353. // 重置该字段的错误信息
  2354. this.formErrors[fieldName] = '';
  2355. // 必填验证
  2356. if (rule.required && !value) {
  2357. this.formErrors[fieldName] = rule.message;
  2358. return false;
  2359. }
  2360. // 正则验证
  2361. if (rule.pattern && value && !rule.pattern.test(value)) {
  2362. this.formErrors[fieldName] = rule.message;
  2363. return false;
  2364. }
  2365. return true;
  2366. },
  2367. validateExpectedSalary(e) {
  2368. const value = e.detail.value;
  2369. console.log(value);
  2370. if (value === '') {
  2371. this.formData.expectedSalary = '';
  2372. this.formErrors.expectedSalary = '';
  2373. return;
  2374. }
  2375. let num = parseFloat(value);
  2376. if (isNaN(num)) {
  2377. this.formErrors.expectedSalary = '请输入有效的数字';
  2378. return;
  2379. }
  2380. if (num < 0) {
  2381. num = 0;
  2382. this.formErrors.expectedSalary = '薪资不能小于0';
  2383. } else if (num > 100000) {
  2384. num = 100000;
  2385. this.formErrors.expectedSalary = '薪资不能超过100000';
  2386. }
  2387. this.formData.expectedSalary = num.toString();
  2388. },
  2389. validateEmployeeCount(e) {
  2390. const value = e.detail.value;
  2391. if (value === '') {
  2392. this.workForm.employeeCount = '';
  2393. this.workErrors.employeeCount = '';
  2394. return;
  2395. }
  2396. let num = parseInt(value);
  2397. if (isNaN(num)) {
  2398. this.workErrors.employeeCount = '请输入有效的数字';
  2399. return;
  2400. }
  2401. if (num < 0) {
  2402. num = 0;
  2403. this.workErrors.employeeCount = '人数不能小于0';
  2404. } else if (num > 10000) {
  2405. num = 10000;
  2406. this.workErrors.employeeCount = '人数不能超过10000';
  2407. }
  2408. this.workForm.employeeCount = num.toString();
  2409. },
  2410. validateMonthlySalary(e) {
  2411. const value = e.detail.value;
  2412. if (value === '') {
  2413. this.workForm.monthlySalary = '';
  2414. this.workErrors.monthlySalary = '';
  2415. return;
  2416. }
  2417. let num = parseInt(value);
  2418. if (isNaN(num)) {
  2419. this.workErrors.monthlySalary = '请输入有效的数字';
  2420. return;
  2421. }
  2422. if (num < 0) {
  2423. num = 0;
  2424. this.workErrors.monthlySalary = '月总收入不能小于0';
  2425. } else if (num > 100000) {
  2426. num = 100000;
  2427. this.workErrors.monthlySalary = '月总收入不能超过100000';
  2428. } else {
  2429. this.workErrors.monthlySalary = '';
  2430. }
  2431. this.workForm.monthlySalary = num.toString();
  2432. },
  2433. // 添加手机号验证方法
  2434. validatePhone(e) {
  2435. const value = e.detail.value;
  2436. if (value.length > 11) {
  2437. this.formData.phone = value.slice(0, 11);
  2438. }
  2439. // 实时验证手机号格式
  2440. if (value && !/^1[3-9]\d{0,9}$/.test(value)) {
  2441. this.formErrors.phone = '请输入正确的手机号码';
  2442. } else {
  2443. this.formErrors.phone = '';
  2444. }
  2445. },
  2446. // 检查是否有未保存的家庭成员表单
  2447. hasUnsavedFamilyMemberForm() {
  2448. return this.familyMemberForm.relation ||
  2449. this.familyMemberForm.name ||
  2450. this.familyMemberForm.workplaceOrAddress ||
  2451. this.familyMemberForm.position ||
  2452. this.familyMemberForm.phone;
  2453. },
  2454. // 检查是否有未保存的教育经历表单
  2455. hasUnsavedEducationForm() {
  2456. return this.educationForm.startTime ||
  2457. this.educationForm.endTime ||
  2458. this.educationForm.schoolName ||
  2459. this.educationForm.major ||
  2460. this.educationForm.degree;
  2461. },
  2462. // 检查是否有未保存的工作经历表单
  2463. hasUnsavedWorkForm() {
  2464. return this.workForm.startTime ||
  2465. this.workForm.endTime ||
  2466. this.workForm.companyName ||
  2467. this.workForm.department ||
  2468. this.workForm.position ||
  2469. this.workForm.employeeCount ||
  2470. this.workForm.monthlySalary ||
  2471. this.workForm.supervisor ||
  2472. this.workForm.supervisorPhone;
  2473. },
  2474. // 自动保存家庭成员
  2475. autoSaveFamilyMember() {
  2476. // 重置错误信息
  2477. this.resetFamilyMemberErrors();
  2478. // 验证必填字段
  2479. let isValid = true;
  2480. // 只验证显示的字段
  2481. if (this.shouldValidateField('relation', 'family') && !this.familyMemberForm.relation) {
  2482. this.familyMemberErrors.relation = '请输入称谓';
  2483. isValid = false;
  2484. }
  2485. if (this.shouldValidateField('name', 'family') && !this.familyMemberForm.name) {
  2486. this.familyMemberErrors.name = '请输入姓名';
  2487. isValid = false;
  2488. }
  2489. if (!isValid) {
  2490. uni.showToast({
  2491. title: '请完善家庭成员必填信息',
  2492. icon: 'none'
  2493. });
  2494. return false;
  2495. }
  2496. // 自动保存逻辑
  2497. if (this.isEditing) {
  2498. this.familyMembers[this.editingIndex] = {...this.familyMemberForm};
  2499. this.isEditing = false;
  2500. this.editingIndex = -1;
  2501. } else {
  2502. this.familyMembers.push({...this.familyMemberForm});
  2503. }
  2504. // 重置表单
  2505. this.resetFamilyMemberForm();
  2506. uni.showToast({
  2507. title: '已自动保存',
  2508. icon: 'success',
  2509. duration: 1500
  2510. });
  2511. return true;
  2512. },
  2513. // 自动保存教育经历
  2514. autoSaveEducation() {
  2515. // 重置错误信息
  2516. this.resetEducationErrors();
  2517. // 验证必填字段
  2518. let isValid = true;
  2519. // 只验证显示的字段
  2520. if (this.shouldValidateField('startTime', 'education') && !this.educationForm.startTime) {
  2521. this.educationErrors.startTime = '请选择开始时间';
  2522. isValid = false;
  2523. }
  2524. if (this.shouldValidateField('endTime', 'education') && !this.educationForm.endTime) {
  2525. this.educationErrors.endTime = '请选择结束时间';
  2526. isValid = false;
  2527. }
  2528. if (this.shouldValidateField('schoolName', 'education') && !this.educationForm.schoolName) {
  2529. this.educationErrors.schoolName = '请输入学校名称';
  2530. isValid = false;
  2531. }
  2532. if (this.shouldValidateField('major', 'education') && !this.educationForm.major) {
  2533. this.educationErrors.major = '请输入专业';
  2534. isValid = false;
  2535. }
  2536. if (this.shouldValidateField('degree', 'education') && !this.educationForm.degree) {
  2537. this.educationErrors.degree = '请选择学历';
  2538. isValid = false;
  2539. }
  2540. if (!isValid) {
  2541. uni.showToast({
  2542. title: '请完善教育经历必填信息',
  2543. icon: 'none'
  2544. });
  2545. return false;
  2546. }
  2547. // 自动保存逻辑
  2548. if (this.isEditingEducation) {
  2549. this.educationList[this.editingEducationIndex] = {...this.educationForm};
  2550. this.isEditingEducation = false;
  2551. this.editingEducationIndex = -1;
  2552. } else {
  2553. this.educationList.push({...this.educationForm});
  2554. }
  2555. // 重置表单
  2556. this.educationForm = {
  2557. startTime: '',
  2558. endTime: '',
  2559. schoolName: '',
  2560. major: '',
  2561. degree: ''
  2562. };
  2563. this.degreeIndex = -1;
  2564. uni.showToast({
  2565. title: '已自动保存',
  2566. icon: 'success',
  2567. duration: 1500
  2568. });
  2569. return true;
  2570. },
  2571. // 自动保存工作经历
  2572. autoSaveWork() {
  2573. // 重置所有工作经历相关的错误信息
  2574. this.workErrors = {
  2575. startTime: '',
  2576. endTime: '',
  2577. companyName: '',
  2578. department: '',
  2579. position: '',
  2580. employeeCount: '',
  2581. monthlySalary: '',
  2582. supervisor: '',
  2583. supervisorPhone: ''
  2584. };
  2585. // 验证必填字段
  2586. let isValid = true;
  2587. // 只验证显示的字段
  2588. if (this.shouldValidateField('startTime', 'work') && !this.workForm.startTime) {
  2589. this.workErrors.startTime = '请选择开始时间';
  2590. isValid = false;
  2591. }
  2592. if (this.shouldValidateField('endTime', 'work') && !this.workForm.endTime) {
  2593. this.workErrors.endTime = '请选择结束时间';
  2594. isValid = false;
  2595. }
  2596. if (this.shouldValidateField('companyName', 'work') && !this.workForm.companyName) {
  2597. this.workErrors.companyName = '请输入单位名称';
  2598. isValid = false;
  2599. }
  2600. if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
  2601. this.workErrors.employeeCount = '请输入单位人数';
  2602. isValid = false;
  2603. }
  2604. if (this.shouldValidateField('department', 'work') && !this.workForm.department) {
  2605. this.workErrors.department = '请输入任职部门';
  2606. isValid = false;
  2607. }
  2608. if (this.shouldValidateField('position', 'work') && !this.workForm.position) {
  2609. this.workErrors.position = '请输入担任职务';
  2610. isValid = false;
  2611. }
  2612. if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
  2613. this.workErrors.employeeCount = '请输入单位人数';
  2614. isValid = false;
  2615. }
  2616. if (this.shouldValidateField('monthlySalary', 'work') && !this.workForm.monthlySalary) {
  2617. this.workErrors.monthlySalary = '请输入月总收入';
  2618. isValid = false;
  2619. }
  2620. if (!isValid) {
  2621. uni.showToast({
  2622. title: '请完善工作经历必填信息',
  2623. icon: 'none'
  2624. });
  2625. return false;
  2626. }
  2627. // 自动保存逻辑
  2628. if (this.isEditingWork) {
  2629. this.workList[this.editingWorkIndex] = {...this.workForm};
  2630. this.isEditingWork = false;
  2631. this.editingWorkIndex = -1;
  2632. } else {
  2633. this.workList.push({...this.workForm});
  2634. }
  2635. // 重置表单
  2636. this.workForm = {
  2637. startTime: '',
  2638. endTime: '',
  2639. companyName: '',
  2640. department: '',
  2641. employeeCount: '',
  2642. position: '',
  2643. monthlySalary: '',
  2644. supervisor: '',
  2645. supervisorPhone: ''
  2646. };
  2647. uni.showToast({
  2648. title: '已自动保存',
  2649. icon: 'success',
  2650. duration: 1500
  2651. });
  2652. return true;
  2653. },
  2654. // 自动保存所有未保存的表单
  2655. autoSaveAllUnsavedForms() {
  2656. // 检查并自动保存家庭成员表单
  2657. if (this.hasUnsavedFamilyMemberForm()) {
  2658. this.autoSaveFamilyMember();
  2659. }
  2660. // 检查并自动保存教育经历表单
  2661. if (this.hasUnsavedEducationForm()) {
  2662. this.autoSaveEducation();
  2663. }
  2664. // 检查并自动保存工作经历表单
  2665. if (this.hasUnsavedWorkForm()) {
  2666. this.autoSaveWork();
  2667. }
  2668. }
  2669. },
  2670. // 添加监听器来清除错误信息
  2671. watch: {
  2672. 'formData.name': function(newVal) {
  2673. if (newVal && this.formErrors.name) {
  2674. this.formErrors.name = '';
  2675. }
  2676. },
  2677. 'formData.idCard': function(newVal) {
  2678. if (newVal && this.formErrors.idCard) {
  2679. this.formErrors.idCard = '';
  2680. }
  2681. },
  2682. 'formData.phone': function(newVal) {
  2683. if (newVal && this.formErrors.phone) {
  2684. this.formErrors.phone = '';
  2685. }
  2686. },
  2687. 'formData.gender': function(newVal) {
  2688. if (newVal && this.formErrors.gender) {
  2689. this.formErrors.gender = '';
  2690. }
  2691. },
  2692. 'formData.ethnic': function(newVal) {
  2693. if (newVal && this.formErrors.ethnic) {
  2694. this.formErrors.ethnic = '';
  2695. }
  2696. },
  2697. 'formData.currentAddress': function(newVal) {
  2698. if (newVal && this.formErrors.currentAddress) {
  2699. this.formErrors.currentAddress = '';
  2700. }
  2701. },
  2702. 'formData.height': function(newVal) {
  2703. if (newVal && this.formErrors.height) {
  2704. this.formErrors.height = '';
  2705. }
  2706. },
  2707. 'formData.weight': function(newVal) {
  2708. if (newVal && this.formErrors.weight) {
  2709. this.formErrors.weight = '';
  2710. }
  2711. },
  2712. 'formData.expectedSalary': function(newVal) {
  2713. if (newVal && this.formErrors.expectedSalary) {
  2714. this.formErrors.expectedSalary = '';
  2715. }
  2716. },
  2717. 'familyMemberForm.relation': function(newVal) {
  2718. if (newVal) this.familyMemberErrors.relation = '';
  2719. },
  2720. 'familyMemberForm.name': function(newVal) {
  2721. if (newVal) this.familyMemberErrors.name = '';
  2722. },
  2723. 'familyMemberForm.phone': function(newVal) {
  2724. if (newVal) this.familyMemberErrors.phone = '';
  2725. },
  2726. /* 'familyMemberForm.workplaceOrAddress': function(newVal) {
  2727. if (newVal) this.familyMemberErrors.workplaceOrAddress = '';
  2728. },
  2729. 'familyMemberForm.position': function(newVal) {
  2730. if (newVal) this.familyMemberErrors.position = '';
  2731. }, */
  2732. 'workForm.companyName': function(newVal) {
  2733. if (newVal && this.workErrors.companyName) {
  2734. this.workErrors.companyName = '';
  2735. }
  2736. },
  2737. 'workForm.department': function(newVal) {
  2738. if (newVal && this.workErrors.department) {
  2739. this.workErrors.department = '';
  2740. }
  2741. },
  2742. 'workForm.position': function(newVal) {
  2743. if (newVal && this.workErrors.position) {
  2744. this.workErrors.position = '';
  2745. }
  2746. },
  2747. 'workForm.employeeCount': function(newVal) {
  2748. if (newVal && this.workErrors.employeeCount) {
  2749. this.workErrors.employeeCount = '';
  2750. }
  2751. },
  2752. 'workForm.monthlySalary': function(newVal) {
  2753. if (newVal && this.workErrors.monthlySalary) {
  2754. this.workErrors.monthlySalary = '';
  2755. }
  2756. },
  2757. 'workForm.supervisor': function(newVal) {
  2758. if (newVal && this.workErrors.supervisor) {
  2759. this.workErrors.supervisor = '';
  2760. }
  2761. },
  2762. // 'workForm.supervisorPhone': function(newVal) {
  2763. // if (newVal && this.workErrors.supervisorPhone) {
  2764. // this.workErrors.supervisorPhone = '';
  2765. // }
  2766. // },
  2767. 'formData.training': function(newVal) {
  2768. if (newVal && this.formErrors.training) {
  2769. this.formErrors.training = '';
  2770. }
  2771. },
  2772. 'educationForm.startTime': function(newVal) {
  2773. if (newVal) this.educationErrors.startTime = '';
  2774. },
  2775. 'educationForm.endTime': function(newVal) {
  2776. if (newVal) this.educationErrors.endTime = '';
  2777. },
  2778. 'educationForm.schoolName': function(newVal) {
  2779. if (newVal) this.educationErrors.schoolName = '';
  2780. },
  2781. 'educationForm.major': function(newVal) {
  2782. if (newVal) this.educationErrors.major = '';
  2783. },
  2784. 'educationForm.degree': function(newVal) {
  2785. if (newVal) this.educationErrors.degree = '';
  2786. },
  2787. // 添加对表单字段的实时验证
  2788. 'formData': {
  2789. handler(newVal) {
  2790. // 只验证当前步骤的字段
  2791. const currentStepFields = {
  2792. 1: ['name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress', 'height', 'weight', 'expectedSalary'],
  2793. 6: ['skills', 'training']
  2794. }[this.currentStep];
  2795. if (currentStepFields) {
  2796. currentStepFields.forEach(field => {
  2797. if (newVal[field] !== undefined && this.shouldValidateField(field)) {
  2798. this.validateField(field, newVal[field]);
  2799. }
  2800. });
  2801. }
  2802. },
  2803. deep: true
  2804. }
  2805. },
  2806. }
  2807. </script>
  2808. <style>
  2809. .personal-container {
  2810. padding: 20rpx;
  2811. }
  2812. .form-title {
  2813. font-size: 36rpx;
  2814. font-weight: bold;
  2815. text-align: center;
  2816. margin-bottom: 30rpx;
  2817. }
  2818. .form-container {
  2819. background-color: #fff;
  2820. border-radius: 10rpx;
  2821. padding: 20rpx;
  2822. }
  2823. .section-title {
  2824. font-size: 32rpx;
  2825. font-weight: bold;
  2826. margin: 30rpx 0 20rpx 10rpx;
  2827. color: #333;
  2828. border-left: 4rpx solid #0039b3;
  2829. padding-left: 15rpx;
  2830. }
  2831. .form-row {
  2832. display: flex;
  2833. flex-direction: row;
  2834. margin-bottom: 20rpx;
  2835. flex-wrap: wrap;
  2836. }
  2837. .form-item {
  2838. flex: 1;
  2839. min-width: 300rpx;
  2840. margin: 10rpx;
  2841. border-bottom: 1px solid #eee;
  2842. padding-bottom: 10rpx;
  2843. }
  2844. .label {
  2845. font-size: 28rpx;
  2846. color: #333;
  2847. margin-right: 10rpx;
  2848. display: block;
  2849. margin-bottom: 10rpx;
  2850. position: relative;
  2851. padding-left: 14rpx; /* 为星号预留空间 */
  2852. }
  2853. input {
  2854. font-size: 28rpx;
  2855. height: 60rpx;
  2856. }
  2857. .picker-text {
  2858. font-size: 28rpx;
  2859. height: 60rpx;
  2860. line-height: 60rpx;
  2861. color: #666;
  2862. }
  2863. .submit-btn {
  2864. margin-top: 40rpx;
  2865. background-color: #0039b3;
  2866. color: #fff;
  2867. }
  2868. .family-members-list {
  2869. margin-top: 20rpx;
  2870. }
  2871. .family-member-item {
  2872. background-color: #f8f8f8;
  2873. border-radius: 8rpx;
  2874. padding: 20rpx;
  2875. margin-bottom: 20rpx;
  2876. }
  2877. .family-member-header {
  2878. display: flex;
  2879. justify-content: space-between;
  2880. align-items: center;
  2881. margin-bottom: 15rpx;
  2882. border-bottom: 1px solid #eee;
  2883. padding-bottom: 10rpx;
  2884. }
  2885. .family-member-title {
  2886. font-size: 30rpx;
  2887. font-weight: bold;
  2888. color: #333;
  2889. }
  2890. .family-member-actions {
  2891. display: flex;
  2892. gap: 20rpx;
  2893. }
  2894. .family-member-edit {
  2895. font-size: 26rpx;
  2896. color: #1890ff;
  2897. }
  2898. .family-member-delete {
  2899. font-size: 26rpx;
  2900. color: #ff4d4f;
  2901. }
  2902. .form-subtitle {
  2903. font-size: 28rpx;
  2904. font-weight: bold;
  2905. margin-bottom: 20rpx;
  2906. display: flex;
  2907. justify-content: space-between;
  2908. align-items: center;
  2909. }
  2910. .cancel-edit {
  2911. font-size: 26rpx;
  2912. color: #999;
  2913. font-weight: normal;
  2914. }
  2915. .family-member-content {
  2916. padding: 10rpx 0;
  2917. }
  2918. .family-member-row {
  2919. display: flex;
  2920. margin-bottom: 10rpx;
  2921. }
  2922. .family-member-label {
  2923. font-size: 26rpx;
  2924. color: #666;
  2925. width: 200rpx;
  2926. }
  2927. .family-member-value {
  2928. font-size: 26rpx;
  2929. color: #333;
  2930. flex: 1;
  2931. }
  2932. .family-member-form {
  2933. background-color: #fff;
  2934. border-radius: 8rpx;
  2935. padding: 20rpx;
  2936. margin-top: 20rpx;
  2937. }
  2938. .form-row button-row {
  2939. display: flex;
  2940. justify-content: center;
  2941. margin-top: 20rpx;
  2942. }
  2943. .form-item button-container {
  2944. display: flex;
  2945. flex-direction: column;
  2946. align-items: center;
  2947. }
  2948. .circle-btn {
  2949. width: 40rpx;
  2950. height: 40rpx;
  2951. border-radius: 50%;
  2952. background-color: #0039b3;
  2953. display: flex;
  2954. justify-content: center;
  2955. align-items: center;
  2956. margin-bottom: 10rpx;
  2957. }
  2958. .btn-icon {
  2959. font-size: 32rpx;
  2960. color: #fff;
  2961. }
  2962. .btn-text {
  2963. font-size: 28rpx;
  2964. color: #333;
  2965. }
  2966. /* 添加圆形按钮相关样式 */
  2967. .button-row {
  2968. justify-content: center;
  2969. margin-top: 30rpx;
  2970. }
  2971. .button-container {
  2972. display: flex;
  2973. flex-direction: column;
  2974. align-items: center;
  2975. border-bottom: none;
  2976. min-width: auto;
  2977. }
  2978. .circle-btn {
  2979. width: 100rpx;
  2980. height: 100rpx;
  2981. border-radius: 50%;
  2982. padding: 0;
  2983. display: flex;
  2984. align-items: center;
  2985. justify-content: center;
  2986. background-color: #0039b3;
  2987. box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.1);
  2988. margin: 0;
  2989. }
  2990. .btn-icon {
  2991. font-size: 50rpx;
  2992. color: #fff;
  2993. line-height: 1;
  2994. }
  2995. .btn-text {
  2996. font-size: 24rpx;
  2997. color: #666;
  2998. margin-top: 10rpx;
  2999. }
  3000. /* 编辑状态下的按钮颜色 */
  3001. .circle-btn.editing {
  3002. background-color: #1890ff;
  3003. }
  3004. /* 移除原来的添加按钮样式 */
  3005. .add-member-btn {
  3006. display: none;
  3007. }
  3008. /* 应聘来源样式 */
  3009. .source-container {
  3010. background-color: #fff;
  3011. border-radius: 10rpx;
  3012. padding: 20rpx;
  3013. margin-bottom: 30rpx;
  3014. }
  3015. .source-row {
  3016. display: flex;
  3017. margin-bottom: 20rpx;
  3018. align-items: flex-start;
  3019. }
  3020. .source-label {
  3021. width: 120rpx;
  3022. font-size: 28rpx;
  3023. color: #333;
  3024. padding-top: 6rpx;
  3025. }
  3026. .source-options {
  3027. flex: 1;
  3028. display: flex;
  3029. flex-wrap: wrap;
  3030. }
  3031. .source-option {
  3032. display: flex;
  3033. align-items: center;
  3034. margin-right: 30rpx;
  3035. margin-bottom: 15rpx;
  3036. }
  3037. .source-option text {
  3038. font-size: 28rpx;
  3039. margin-left: 8rpx;
  3040. }
  3041. .other-option {
  3042. flex-basis: 100%;
  3043. margin-top: 10rpx;
  3044. }
  3045. .other-option input {
  3046. border-bottom: 1px solid #eee;
  3047. width: 300rpx;
  3048. margin-left: 10rpx;
  3049. font-size: 28rpx;
  3050. }
  3051. /* 教育经历样式 */
  3052. .education-list {
  3053. margin-top: 20rpx;
  3054. }
  3055. .education-item {
  3056. background-color: #f8f8f8;
  3057. border-radius: 8rpx;
  3058. padding: 20rpx;
  3059. margin-bottom: 20rpx;
  3060. }
  3061. .education-header {
  3062. display: flex;
  3063. justify-content: space-between;
  3064. align-items: center;
  3065. margin-bottom: 15rpx;
  3066. border-bottom: 1px solid #eee;
  3067. padding-bottom: 10rpx;
  3068. }
  3069. .education-title {
  3070. font-size: 30rpx;
  3071. font-weight: bold;
  3072. color: #333;
  3073. }
  3074. .education-actions {
  3075. display: flex;
  3076. gap: 20rpx;
  3077. }
  3078. .education-edit {
  3079. font-size: 26rpx;
  3080. color: #1890ff;
  3081. }
  3082. .education-delete {
  3083. font-size: 26rpx;
  3084. color: #ff4d4f;
  3085. }
  3086. .education-content {
  3087. padding: 10rpx 0;
  3088. }
  3089. .education-row {
  3090. display: flex;
  3091. margin-bottom: 10rpx;
  3092. }
  3093. .education-label {
  3094. font-size: 26rpx;
  3095. color: #666;
  3096. width: 150rpx;
  3097. }
  3098. .education-value {
  3099. font-size: 26rpx;
  3100. color: #333;
  3101. flex: 1;
  3102. }
  3103. .education-form {
  3104. background-color: #fff;
  3105. border-radius: 8rpx;
  3106. padding: 20rpx;
  3107. margin-top: 20rpx;
  3108. }
  3109. .date-range {
  3110. display: flex;
  3111. align-items: center;
  3112. justify-content: space-around;
  3113. }
  3114. .date-separator {
  3115. margin: 0 10rpx;
  3116. color: #666;
  3117. }
  3118. /* 专业技能和培训样式 */
  3119. .skills-container, .training-container {
  3120. background-color: #fff;
  3121. border-radius: 10rpx;
  3122. padding: 20rpx;
  3123. margin-bottom: 20rpx;
  3124. }
  3125. .skills-textarea, .training-textarea {
  3126. width: 100%;
  3127. height: 200rpx;
  3128. font-size: 28rpx;
  3129. line-height: 1.5;
  3130. padding: 10rpx;
  3131. box-sizing: border-box;
  3132. border: 1px solid #eee;
  3133. border-radius: 6rpx;
  3134. }
  3135. /* 工作经历样式 */
  3136. .work-list {
  3137. margin-top: 20rpx;
  3138. }
  3139. .work-item {
  3140. background-color: #f8f8f8;
  3141. border-radius: 8rpx;
  3142. padding: 20rpx;
  3143. margin-bottom: 20rpx;
  3144. }
  3145. .work-header {
  3146. display: flex;
  3147. justify-content: space-between;
  3148. align-items: center;
  3149. margin-bottom: 15rpx;
  3150. border-bottom: 1px solid #eee;
  3151. padding-bottom: 10rpx;
  3152. }
  3153. .work-title {
  3154. font-size: 30rpx;
  3155. font-weight: bold;
  3156. color: #333;
  3157. }
  3158. .work-actions {
  3159. display: flex;
  3160. gap: 20rpx;
  3161. }
  3162. .work-edit {
  3163. font-size: 26rpx;
  3164. color: #1890ff;
  3165. }
  3166. .work-delete {
  3167. font-size: 26rpx;
  3168. color: #ff4d4f;
  3169. }
  3170. .work-content {
  3171. padding: 10rpx 0;
  3172. }
  3173. .work-row {
  3174. display: flex;
  3175. margin-bottom: 10rpx;
  3176. }
  3177. .work-label {
  3178. font-size: 26rpx;
  3179. color: #666;
  3180. width: 150rpx;
  3181. }
  3182. .work-value {
  3183. font-size: 26rpx;
  3184. color: #333;
  3185. flex: 1;
  3186. }
  3187. .work-form {
  3188. background-color: #fff;
  3189. border-radius: 8rpx;
  3190. padding: 20rpx;
  3191. margin-top: 20rpx;
  3192. }
  3193. /* 步骤指示器样式 */
  3194. .steps-indicator {
  3195. display: flex;
  3196. justify-content: space-between;
  3197. margin-bottom: 30rpx;
  3198. padding: 20rpx;
  3199. background-color: #fff;
  3200. border-radius: 10rpx;
  3201. overflow-x: auto;
  3202. }
  3203. .step-item {
  3204. display: flex;
  3205. flex-direction: column;
  3206. align-items: center;
  3207. position: relative;
  3208. min-width: 120rpx;
  3209. }
  3210. .step-item:not(:last-child)::after {
  3211. content: '';
  3212. position: absolute;
  3213. top: 20rpx;
  3214. right: -50%;
  3215. width: 100%;
  3216. height: 2rpx;
  3217. background-color: #ddd;
  3218. z-index: 1;
  3219. }
  3220. .step-item.active:not(:last-child)::after {
  3221. background-color: #0039b3;
  3222. }
  3223. .step-number {
  3224. width: 40rpx;
  3225. height: 40rpx;
  3226. border-radius: 50%;
  3227. background-color: #ddd;
  3228. color: #fff;
  3229. display: flex;
  3230. justify-content: center;
  3231. align-items: center;
  3232. font-size: 24rpx;
  3233. margin-bottom: 10rpx;
  3234. position: relative;
  3235. z-index: 2;
  3236. }
  3237. .step-item.active .step-number {
  3238. background-color: #0039b3;
  3239. }
  3240. .step-item.current .step-number {
  3241. background-color: #0039b3;
  3242. box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.2);
  3243. }
  3244. .step-name {
  3245. font-size: 22rpx;
  3246. color: #999;
  3247. text-align: center;
  3248. }
  3249. .step-item.active .step-name {
  3250. color: #333;
  3251. }
  3252. .step-item.current .step-name {
  3253. color: #0039b3;
  3254. font-weight: bold;
  3255. }
  3256. /* 导航按钮样式 */
  3257. .nav-buttons {
  3258. display: flex;
  3259. justify-content: space-between;
  3260. margin-top: 40rpx;
  3261. padding: 0 20rpx;
  3262. }
  3263. .nav-btn {
  3264. flex: 1;
  3265. margin: 0 10rpx;
  3266. height: 80rpx;
  3267. line-height: 80rpx;
  3268. text-align: center;
  3269. border-radius: 40rpx;
  3270. font-size: 28rpx;
  3271. }
  3272. .prev-btn {
  3273. background-color: #f0f0f0;
  3274. color: #666;
  3275. }
  3276. .next-btn {
  3277. background-color: #0039b3;
  3278. color: #fff;
  3279. }
  3280. .submit-btn {
  3281. flex: 1;
  3282. margin: 0 10rpx;
  3283. height: 80rpx;
  3284. line-height: 80rpx;
  3285. text-align: center;
  3286. border-radius: 40rpx;
  3287. font-size: 28rpx;
  3288. background-color: #0039b3;
  3289. color: #fff;
  3290. }
  3291. /* 确认提交页样式 */
  3292. .confirm-container {
  3293. background-color: #fff;
  3294. border-radius: 10rpx;
  3295. padding: 20rpx;
  3296. margin-bottom: 30rpx;
  3297. }
  3298. .confirm-message {
  3299. padding: 20rpx;
  3300. background-color: #f6f6f6;
  3301. border-radius: 8rpx;
  3302. margin-bottom: 20rpx;
  3303. }
  3304. .info-summary {
  3305. padding: 20rpx;
  3306. }
  3307. .summary-item {
  3308. display: flex;
  3309. margin-bottom: 15rpx;
  3310. }
  3311. .summary-label {
  3312. width: 150rpx;
  3313. font-size: 28rpx;
  3314. color: #666;
  3315. }
  3316. .summary-value {
  3317. flex: 1;
  3318. font-size: 28rpx;
  3319. color: #333;
  3320. }
  3321. .input-error {
  3322. border-bottom: 1px solid #ff4d4f !important;
  3323. }
  3324. .error-message {
  3325. color: #ff4d4f;
  3326. font-size: 24rpx;
  3327. margin-top: 6rpx;
  3328. display: block;
  3329. }
  3330. /* 添加承诺书弹框样式 */
  3331. .promise-modal {
  3332. position: fixed;
  3333. top: 0;
  3334. left: 0;
  3335. right: 0;
  3336. bottom: 0;
  3337. background-color: rgba(0, 0, 0, 0.5);
  3338. z-index: 999;
  3339. display: flex;
  3340. justify-content: center;
  3341. align-items: center;
  3342. }
  3343. .promise-content {
  3344. width: 80%;
  3345. max-width: 600rpx;
  3346. background-color: #fff;
  3347. border-radius: 12rpx;
  3348. padding: 30rpx;
  3349. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  3350. }
  3351. .promise-title {
  3352. font-size: 34rpx;
  3353. font-weight: bold;
  3354. text-align: center;
  3355. margin-bottom: 20rpx;
  3356. color: #333;
  3357. }
  3358. .promise-text {
  3359. height: 600rpx;
  3360. margin-bottom: 20rpx;
  3361. /* padding: 20rpx; */
  3362. background-color: #f8f8f8;
  3363. border-radius: 8rpx;
  3364. font-size: 28rpx;
  3365. line-height: 1.6;
  3366. color: #333;
  3367. }
  3368. .promise-checkbox {
  3369. display: flex;
  3370. align-items: center;
  3371. margin-bottom: 30rpx;
  3372. padding: 0 10rpx;
  3373. }
  3374. .promise-checkbox text {
  3375. font-size: 28rpx;
  3376. margin-left: 10rpx;
  3377. color: #333;
  3378. }
  3379. .promise-buttons {
  3380. display: flex;
  3381. justify-content: center;
  3382. }
  3383. .promise-btn {
  3384. width: 200rpx;
  3385. height: 80rpx;
  3386. line-height: 80rpx;
  3387. text-align: center;
  3388. border-radius: 40rpx;
  3389. font-size: 28rpx;
  3390. }
  3391. .confirm-btn {
  3392. background-color: #0039b3;
  3393. color: #fff;
  3394. }
  3395. .confirm-btn[disabled] {
  3396. background-color: #cccccc;
  3397. color: #ffffff;
  3398. }
  3399. /* Loading indicator styles */
  3400. .loading-container {
  3401. position: fixed;
  3402. top: 0;
  3403. left: 0;
  3404. right: 0;
  3405. bottom: 0;
  3406. background-color: rgba(255, 255, 255, 0.8);
  3407. display: flex;
  3408. flex-direction: column;
  3409. justify-content: center;
  3410. align-items: center;
  3411. z-index: 1000;
  3412. }
  3413. .loading-spinner {
  3414. width: 60rpx;
  3415. height: 60rpx;
  3416. border: 6rpx solid #f3f3f3;
  3417. border-top: 6rpx solid #0039b3;
  3418. border-radius: 50%;
  3419. animation: spin 1s linear infinite;
  3420. margin-bottom: 20rpx;
  3421. }
  3422. .loading-text {
  3423. font-size: 28rpx;
  3424. color: #666;
  3425. }
  3426. @keyframes spin {
  3427. 0% { transform: rotate(0deg); }
  3428. 100% { transform: rotate(360deg); }
  3429. }
  3430. /* 添加开关样式 */
  3431. .form-item switch {
  3432. margin-top: 10rpx;
  3433. }
  3434. /* 修改必填项标签的样式 */
  3435. .label.required::before {
  3436. content: '*';
  3437. color: #ff4d4f;
  3438. margin-right: 4rpx;
  3439. position: absolute;
  3440. left: 0;
  3441. top: -4rpx;
  3442. }
  3443. /* 修改必填项标签的样式 */
  3444. /* .label.required::after {
  3445. content: '*';
  3446. color: #ff4d4f;
  3447. margin-left: 4rpx;
  3448. } */
  3449. </style>