Personal.vue 110 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858
  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="defaultEducationStartTime"
  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="defaultEducationEndTime"
  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="defaultWorkStartTime"
  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="defaultWorkEndTime"
  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. // 获取教育经历开始时间的初始值(默认为当前月份1号)
  1049. defaultEducationStartTime() {
  1050. // 如果有值,返回当前值;否则返回当前月份的1号作为picker的初始值
  1051. if (this.educationForm.startTime) {
  1052. return this.educationForm.startTime;
  1053. }
  1054. // 返回当前月份的1号
  1055. const now = new Date();
  1056. const year = now.getFullYear();
  1057. const month = String(now.getMonth() + 1).padStart(2, '0');
  1058. return `${year}-${month}-01`;
  1059. },
  1060. // 获取教育经历结束时间的初始值(默认为当前月份1号)
  1061. defaultEducationEndTime() {
  1062. // 如果有值,返回当前值;否则返回当前月份的1号作为picker的初始值
  1063. if (this.educationForm.endTime) {
  1064. return this.educationForm.endTime;
  1065. }
  1066. // 返回当前月份的1号
  1067. const now = new Date();
  1068. const year = now.getFullYear();
  1069. const month = String(now.getMonth() + 1).padStart(2, '0');
  1070. return `${year}-${month}-01`;
  1071. },
  1072. // 获取工作经历开始时间的初始值(默认为当前月份1号)
  1073. defaultWorkStartTime() {
  1074. // 如果有值,返回当前值;否则返回当前月份的1号作为picker的初始值
  1075. if (this.workForm.startTime) {
  1076. return this.workForm.startTime;
  1077. }
  1078. // 返回当前月份的1号
  1079. const now = new Date();
  1080. const year = now.getFullYear();
  1081. const month = String(now.getMonth() + 1).padStart(2, '0');
  1082. return `${year}-${month}-01`;
  1083. },
  1084. // 获取工作经历结束时间的初始值(默认为当前月份1号)
  1085. defaultWorkEndTime() {
  1086. // 如果有值,返回当前值;否则返回当前月份的1号作为picker的初始值
  1087. if (this.workForm.endTime) {
  1088. return this.workForm.endTime;
  1089. }
  1090. // 返回当前月份的1号
  1091. const now = new Date();
  1092. const year = now.getFullYear();
  1093. const month = String(now.getMonth() + 1).padStart(2, '0');
  1094. return `${year}-${month}-01`;
  1095. },
  1096. },
  1097. methods: {
  1098. // 确保当前步骤是有效的(如果需要显示的话)
  1099. ensureValidStep() {
  1100. const currentStepId = this.currentStep;
  1101. let shouldShowCurrentStep = true;
  1102. // 检查当前步骤是否需要显示
  1103. switch (currentStepId) {
  1104. case 3: // 家庭成员
  1105. shouldShowCurrentStep = this.shouldShowFamilyStep;
  1106. break;
  1107. case 5: // 教育经历
  1108. shouldShowCurrentStep = this.shouldShowEducationStep;
  1109. break;
  1110. case 6: // 专业技能
  1111. shouldShowCurrentStep = this.shouldShowSkillsStep;
  1112. break;
  1113. case 8: // 工作经历
  1114. shouldShowCurrentStep = this.shouldShowWorkStep;
  1115. break;
  1116. default:
  1117. // 非特殊步骤默认显示
  1118. shouldShowCurrentStep = true;
  1119. }
  1120. // 如果当前步骤不需要显示,跳转到最后一个可见步骤
  1121. if (!shouldShowCurrentStep) {
  1122. this.jumpToLastVisibleStep();
  1123. }
  1124. },
  1125. // 跳转到最后一个可见步骤
  1126. jumpToLastVisibleStep() {
  1127. let lastVisibleStepId = null;
  1128. // 从后往前查找最后一个需要显示的步骤
  1129. for (let i = this.steps.length - 1; i >= 0; i--) {
  1130. const stepId = this.steps[i].id;
  1131. let shouldShowStep = false;
  1132. switch (stepId) {
  1133. case 3: // 家庭成员
  1134. shouldShowStep = this.shouldShowFamilyStep;
  1135. break;
  1136. case 5: // 教育经历
  1137. shouldShowStep = this.shouldShowEducationStep;
  1138. break;
  1139. case 6: // 专业技能
  1140. shouldShowStep = this.shouldShowSkillsStep;
  1141. break;
  1142. case 8: // 工作经历
  1143. shouldShowStep = this.shouldShowWorkStep;
  1144. break;
  1145. default:
  1146. // 非特殊步骤默认显示
  1147. shouldShowStep = true;
  1148. }
  1149. if (shouldShowStep) {
  1150. lastVisibleStepId = stepId;
  1151. break;
  1152. }
  1153. }
  1154. // 跳转到最后一个可见步骤
  1155. if (lastVisibleStepId) {
  1156. console.log('跳转到最后一个可见步骤:', lastVisibleStepId);
  1157. this.currentStep = lastVisibleStepId;
  1158. // 滚动到页面顶部
  1159. uni.pageScrollTo({
  1160. scrollTop: 0,
  1161. duration: 300
  1162. });
  1163. }
  1164. },
  1165. // 输入时限制小数位数
  1166. handleInput(event, field, maxDecimals) {
  1167. let value = event.detail.value;
  1168. // 1. 过滤非法字符并限制小数位
  1169. value = value
  1170. .replace(/[^\d.-]/g, '')
  1171. .replace(/(\..*)\./g, '$1')
  1172. .replace(/(-\d*)-/g, '$1')
  1173. .replace(new RegExp(`^(-?\\d*\\.\\d{${maxDecimals}}).*$`), '$1');
  1174. // 2. 处理以小数点开头的情况
  1175. if (value.startsWith('.')) {
  1176. value = '0' + value;
  1177. }
  1178. // 3. 更新数据
  1179. this.formData[field] = value;
  1180. // 4. 强制同步输入框显示
  1181. this.$nextTick(() => {
  1182. event.target.value = value;
  1183. });
  1184. },
  1185. // 失焦时补全小数位
  1186. handleBlur(field, precision = 2) {
  1187. const val = this.formData[field];
  1188. if (val === '' || val === undefined || val === null) return;
  1189. const num = parseFloat(val);
  1190. if (!isNaN(num)) {
  1191. this.formData[field] = num.toFixed(precision);
  1192. } else {
  1193. this.formData[field] = '';
  1194. }
  1195. },
  1196. // 添加承诺书相关方法
  1197. togglePromiseChecked() {
  1198. this.promiseChecked = !this.promiseChecked;
  1199. },
  1200. confirmPromise() {
  1201. if (this.promiseChecked) {
  1202. this.showPromiseModal = false;
  1203. } else {
  1204. uni.showToast({
  1205. title: '请先阅读并同意承诺书内容',
  1206. icon: 'none'
  1207. });
  1208. }
  1209. },
  1210. // 添加字段是否需要验证的判断方法
  1211. shouldValidateField(fieldName, section) {
  1212. section = section || 'profile';
  1213. switch (section) {
  1214. case 'profile':
  1215. const fieldShowMap = {
  1216. 'name': this.showNameField,
  1217. 'gender': this.showGenderField,
  1218. 'phone': this.showPhoneField,
  1219. 'idCard': this.showIdCardField,
  1220. 'ethnic': this.showEthnicField,
  1221. 'height': this.showHeightField,
  1222. 'weight': this.showWeightField,
  1223. 'currentAddress': this.showCurrentAddress, // 现居住地址总是显示和必填
  1224. 'expectedSalary': this.showExpectedSalary, // 期望薪资总是显示
  1225. 'skills': this.showRequireTrainingInfoField, // 专业技能根据配置显示和必填
  1226. 'training': this.showRequireProfessionalSkillsField, // 培训经历根据配置显示和必填
  1227. 'threePeriod': this.formData.gender === '女' // 只有女性时才需要验证三期状态
  1228. };
  1229. return fieldShowMap[fieldName] !== false;
  1230. case 'family':
  1231. const familyFieldShowMap = {
  1232. 'relation': this.showFamilyRelationField,
  1233. 'name': this.showFamilyNameField,
  1234. 'phone': this.showFamilyPhoneField,
  1235. 'workplaceOrAddress': this.showFamilyWorkplaceField,
  1236. 'position': this.showFamilyPositionField,
  1237. 'isEmergencyContact':this.showFamilyisEmergency
  1238. };
  1239. return familyFieldShowMap[fieldName] !== false;
  1240. case 'education':
  1241. const educationFieldShowMap = {
  1242. 'startTime': this.showEducationTimeField,
  1243. 'endTime': this.showEducationTimeField,
  1244. 'schoolName': this.showEducationSchoolField,
  1245. 'major': this.showEducationMajorField,
  1246. 'degree': this.showEducationDegreeField
  1247. };
  1248. return educationFieldShowMap[fieldName] !== false;
  1249. case 'work':
  1250. const workFieldShowMap = {
  1251. 'startTime': this.showWorkTimeField,
  1252. 'endTime': this.showWorkTimeField,
  1253. 'companyName': this.showWorkCompanyField,
  1254. 'department': this.showWorkDepartmentField,
  1255. 'position': this.showWorkPositionField,
  1256. 'employeeCount': this.showWorkEmployeeCountField,
  1257. 'monthlySalary': this.showWorkMonthlySalary, // 月薪总是需要验证
  1258. 'supervisor': this.showWorkSupervisor, // 直接领导总是需要验证
  1259. 'supervisorPhone': this.showWorkSupervisorPhone // 领导电话总是需要验证
  1260. };
  1261. return workFieldShowMap[fieldName] !== false;
  1262. default:
  1263. return true;
  1264. }
  1265. },
  1266. bindGenderChange(e) {
  1267. this.genderIndex = e.detail.value;
  1268. this.formData.gender = this.genderOptions[this.genderIndex];
  1269. // 清除性别的错误提示
  1270. if (this.formErrors.gender) {
  1271. this.formErrors.gender = '';
  1272. }
  1273. // 如果性别从女变为男,清空三期选择
  1274. if (this.formData.gender !== '女') {
  1275. this.formData.threePeriod = '';
  1276. this.threePeriodIndex = -1;
  1277. this.formErrors.threePeriod = ''; // 清除三期状态的错误提示
  1278. }
  1279. },
  1280. bindThreePeriodChange(e) {
  1281. this.threePeriodIndex = e.detail.value;
  1282. this.formData.threePeriod = this.threePeriodOptions[this.threePeriodIndex];
  1283. // 清除三期状态的错误提示
  1284. if (this.formErrors.threePeriod) {
  1285. this.formErrors.threePeriod = '';
  1286. }
  1287. },
  1288. bindPoliticalChange(e) {
  1289. this.politicalIndex = e.detail.value;
  1290. this.formData.political = this.politicalOptions[this.politicalIndex];
  1291. },
  1292. bindEthnicChange(e) {
  1293. this.ethnicIndex = e.detail.value;
  1294. this.formData.ethnic = this.ethnicOptions[this.ethnicIndex];
  1295. // 清除民族的错误提示
  1296. if (this.formErrors.ethnic) {
  1297. this.formErrors.ethnic = '';
  1298. }
  1299. },
  1300. bindMarriageChange(e) {
  1301. this.marriageIndex = e.detail.value;
  1302. this.formData.marriage = this.marriageOptions[this.marriageIndex];
  1303. },
  1304. bindDateChange(e) {
  1305. this.formData.birthDate = e.detail.value;
  1306. },
  1307. saveFamilyMember() {
  1308. // 重置错误信息
  1309. this.resetFamilyMemberErrors();
  1310. // 验证必填字段
  1311. let isValid = true;
  1312. // 只验证显示的字段
  1313. if (this.shouldValidateField('relation', 'family') && !this.familyMemberForm.relation) {
  1314. this.familyMemberErrors.relation = '请输入称谓';
  1315. isValid = false;
  1316. }
  1317. if (this.shouldValidateField('name', 'family') && !this.familyMemberForm.name) {
  1318. this.familyMemberErrors.name = '请输入姓名';
  1319. isValid = false;
  1320. }
  1321. // if (this.shouldValidateField('workplaceOrAddress', 'family') && !this.familyMemberForm.workplaceOrAddress) {
  1322. // this.familyMemberErrors.workplaceOrAddress = '请输入工作单位/家庭地址';
  1323. // isValid = false;
  1324. // }
  1325. // if (this.shouldValidateField('position', 'family') && !this.familyMemberForm.position) {
  1326. // this.familyMemberErrors.position = '请输入职务';
  1327. // isValid = false;
  1328. // }
  1329. // if (this.shouldValidateField('phone', 'family') && !this.familyMemberForm.phone) {
  1330. // this.familyMemberErrors.phone = '请输入联系电话';
  1331. // isValid = false;
  1332. // } else
  1333. if (this.shouldValidateField('phone', 'family') && this.familyMemberForm.phone && !/^1[3-9]\d{9}$/.test(this.familyMemberForm.phone)) {
  1334. this.familyMemberErrors.phone = '请输入正确的手机号';
  1335. isValid = false;
  1336. }
  1337. if (!isValid) {
  1338. uni.showToast({
  1339. title: '请完善家庭成员信息',
  1340. icon: 'none'
  1341. });
  1342. return;
  1343. }
  1344. // 原有的保存逻辑
  1345. if (this.isEditing) {
  1346. this.familyMembers[this.editingIndex] = {...this.familyMemberForm};
  1347. uni.showToast({
  1348. title: '修改成功',
  1349. icon: 'success'
  1350. });
  1351. this.isEditing = false;
  1352. this.editingIndex = -1;
  1353. } else {
  1354. this.familyMembers.push({...this.familyMemberForm});
  1355. uni.showToast({
  1356. title: '添加成功',
  1357. icon: 'success'
  1358. });
  1359. }
  1360. // 重置表单和错误信息
  1361. this.resetFamilyMemberForm();
  1362. },
  1363. // 添加重置错误信息的方法
  1364. resetFamilyMemberErrors() {
  1365. this.familyMemberErrors = {
  1366. relation: '',
  1367. name: '',
  1368. phone: '',
  1369. workplaceOrAddress: '',
  1370. position: ''
  1371. };
  1372. },
  1373. // 修改重置表单的方法
  1374. resetFamilyMemberForm() {
  1375. this.familyMemberForm = {
  1376. relation: '',
  1377. name: '',
  1378. workplaceOrAddress: '',
  1379. position: '',
  1380. phone: '',
  1381. isEmergencyContact: false
  1382. };
  1383. this.resetFamilyMemberErrors();
  1384. },
  1385. editFamilyMember(index) {
  1386. this.isEditing = true;
  1387. this.editingIndex = index;
  1388. this.familyMemberForm = {...this.familyMembers[index]};
  1389. uni.pageScrollTo({
  1390. selector: '.family-member-form',
  1391. duration: 300
  1392. });
  1393. },
  1394. cancelEdit() {
  1395. this.isEditing = false;
  1396. this.editingIndex = -1;
  1397. this.familyMemberForm = {
  1398. relation: '',
  1399. name: '',
  1400. workplaceOrAddress: '',
  1401. position: '',
  1402. phone: '',
  1403. isEmergencyContact: false
  1404. };
  1405. },
  1406. deleteFamilyMember(index) {
  1407. if (this.isEditing && this.editingIndex === index) {
  1408. this.cancelEdit();
  1409. }
  1410. this.familyMembers.splice(index, 1);
  1411. uni.showToast({
  1412. title: '已删除',
  1413. icon: 'none'
  1414. });
  1415. },
  1416. // 选择应聘来源类型
  1417. selectSourceType(type) {
  1418. this.formData.sourceType = type;
  1419. if (type === 'social') {
  1420. // 默认选择第一个社招来源
  1421. this.formData.socialSource = 'BOSS';
  1422. } else {
  1423. // 清空社招来源
  1424. this.formData.socialSource = '';
  1425. }
  1426. },
  1427. // 选择社招来源
  1428. selectSocialSource(source) {
  1429. this.formData.sourceType = 'social';
  1430. this.formData.socialSource = source;
  1431. },
  1432. // 教育经历相关方法
  1433. bindStartTimeChange(e) {
  1434. const startTime = e.detail.value;
  1435. if (this.educationForm.endTime && startTime > this.educationForm.endTime) {
  1436. uni.showToast({
  1437. title: '开始时间不能大于结束时间',
  1438. icon: 'none'
  1439. });
  1440. return;
  1441. }
  1442. this.educationForm.startTime = startTime;
  1443. this.educationErrors.startTime = false;
  1444. },
  1445. bindEndTimeChange(e) {
  1446. const endTime = e.detail.value;
  1447. if (this.educationForm.startTime && endTime < this.educationForm.startTime) {
  1448. uni.showToast({
  1449. title: '结束时间不能小于开始时间',
  1450. icon: 'none'
  1451. });
  1452. return;
  1453. }
  1454. this.educationForm.endTime = endTime;
  1455. this.educationErrors.endTime = false;
  1456. },
  1457. bindDegreeChange(e) {
  1458. this.degreeIndex = e.detail.value;
  1459. this.educationForm.degree = this.degreeOptions[this.degreeIndex];
  1460. },
  1461. saveEducation() {
  1462. // 重置错误信息
  1463. this.resetEducationErrors();
  1464. // 验证必填字段
  1465. let isValid = true;
  1466. // 只验证显示的字段
  1467. if (this.shouldValidateField('startTime', 'education') && !this.educationForm.startTime) {
  1468. this.educationErrors.startTime = '请选择开始时间';
  1469. isValid = false;
  1470. }
  1471. if (this.shouldValidateField('endTime', 'education') && !this.educationForm.endTime) {
  1472. this.educationErrors.endTime = '请选择结束时间';
  1473. isValid = false;
  1474. }
  1475. if (this.shouldValidateField('schoolName', 'education') && !this.educationForm.schoolName) {
  1476. this.educationErrors.schoolName = '请输入学校名称';
  1477. isValid = false;
  1478. }
  1479. if (this.shouldValidateField('major', 'education') && !this.educationForm.major) {
  1480. this.educationErrors.major = '请输入专业';
  1481. isValid = false;
  1482. }
  1483. if (this.shouldValidateField('degree', 'education') && !this.educationForm.degree) {
  1484. this.educationErrors.degree = '请选择学历';
  1485. isValid = false;
  1486. }
  1487. if (!isValid) {
  1488. uni.showToast({
  1489. title: '请完善教育经历信息',
  1490. icon: 'none'
  1491. });
  1492. return;
  1493. }
  1494. // 验证通过后的保存逻辑
  1495. if (this.isEditingEducation) {
  1496. this.educationList[this.editingEducationIndex] = {...this.educationForm};
  1497. uni.showToast({
  1498. title: '修改成功',
  1499. icon: 'success'
  1500. });
  1501. this.isEditingEducation = false;
  1502. this.editingEducationIndex = -1;
  1503. } else {
  1504. this.educationList.push({...this.educationForm});
  1505. uni.showToast({
  1506. title: '添加成功',
  1507. icon: 'success'
  1508. });
  1509. }
  1510. // 重置表单
  1511. this.educationForm = {
  1512. startTime: '',
  1513. endTime: '',
  1514. schoolName: '',
  1515. major: '',
  1516. degree: ''
  1517. };
  1518. this.degreeIndex = -1;
  1519. },
  1520. editEducation(index) {
  1521. this.isEditingEducation = true;
  1522. this.editingEducationIndex = index;
  1523. this.educationForm = {...this.educationList[index]};
  1524. // 设置学历索引
  1525. this.degreeIndex = this.degreeOptions.findIndex(item => item === this.educationForm.degree);
  1526. uni.pageScrollTo({
  1527. selector: '.education-form',
  1528. duration: 300
  1529. });
  1530. },
  1531. cancelEditEducation() {
  1532. this.isEditingEducation = false;
  1533. this.editingEducationIndex = -1;
  1534. this.educationForm = {
  1535. startTime: '',
  1536. endTime: '',
  1537. schoolName: '',
  1538. major: '',
  1539. degree: ''
  1540. };
  1541. this.degreeIndex = -1;
  1542. },
  1543. deleteEducation(index) {
  1544. if (this.isEditingEducation && this.editingEducationIndex === index) {
  1545. this.cancelEditEducation();
  1546. }
  1547. this.educationList.splice(index, 1);
  1548. uni.showToast({
  1549. title: '已删除',
  1550. icon: 'none'
  1551. });
  1552. },
  1553. // 工作经历相关方法
  1554. bindWorkStartTimeChange(e) {
  1555. const startTime = e.detail.value;
  1556. if (this.workForm.endTime && startTime > this.workForm.endTime) {
  1557. uni.showToast({
  1558. title: '开始时间不能大于结束时间',
  1559. icon: 'none'
  1560. });
  1561. return;
  1562. }
  1563. this.workForm.startTime = startTime;
  1564. this.workErrors.startTime = false;
  1565. },
  1566. bindWorkEndTimeChange(e) {
  1567. const endTime = e.detail.value;
  1568. if (this.workForm.startTime && endTime < this.workForm.startTime) {
  1569. uni.showToast({
  1570. title: '结束时间不能小于开始时间',
  1571. icon: 'none'
  1572. });
  1573. return;
  1574. }
  1575. this.workForm.endTime = endTime;
  1576. this.workErrors.endTime = false;
  1577. },
  1578. saveWork() {
  1579. // 重置所有工作经历相关的错误信息
  1580. this.workErrors = {
  1581. startTime: '',
  1582. endTime: '',
  1583. companyName: '',
  1584. department: '',
  1585. position: '',
  1586. employeeCount: '',
  1587. monthlySalary: '',
  1588. supervisor: '',
  1589. supervisorPhone: ''
  1590. };
  1591. // 验证必填字段
  1592. let isValid = true;
  1593. // 只验证显示的字段
  1594. if (this.shouldValidateField('startTime', 'work') && !this.workForm.startTime) {
  1595. this.workErrors.startTime = '请选择开始时间';
  1596. isValid = false;
  1597. }
  1598. if (this.shouldValidateField('endTime', 'work') && !this.workForm.endTime) {
  1599. this.workErrors.endTime = '请选择结束时间';
  1600. isValid = false;
  1601. }
  1602. if (this.shouldValidateField('companyName', 'work') && !this.workForm.companyName) {
  1603. this.workErrors.companyName = '请输入单位名称';
  1604. isValid = false;
  1605. }
  1606. if (this.shouldValidateField('department', 'work') && !this.workForm.department) {
  1607. this.workErrors.department = '请输入任职部门';
  1608. isValid = false;
  1609. }
  1610. if (this.shouldValidateField('position', 'work') && !this.workForm.position) {
  1611. this.workErrors.position = '请输入担任职务';
  1612. isValid = false;
  1613. }
  1614. if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
  1615. this.workErrors.employeeCount = '请输入单位人数';
  1616. isValid = false;
  1617. }
  1618. if (this.shouldValidateField('monthlySalary', 'work') && !this.workForm.monthlySalary) {
  1619. this.workErrors.monthlySalary = '请输入月总收入';
  1620. isValid = false;
  1621. }
  1622. // if (this.shouldValidateField('supervisor', 'work') && !this.workForm.supervisor) {
  1623. // this.workErrors.supervisor = '请输入直属上级';
  1624. // isValid = false;
  1625. // }
  1626. // if (this.shouldValidateField('supervisorPhone', 'work') && !this.workForm.supervisorPhone) {
  1627. // this.workErrors.supervisorPhone = '请输入直属上级电话';
  1628. // isValid = false;
  1629. // }
  1630. // 如果验证不通过,直接返回
  1631. if (!isValid) {
  1632. uni.showToast({
  1633. title: '请完善工作经历信息',
  1634. icon: 'none'
  1635. });
  1636. return;
  1637. }
  1638. // 验证通过后的保存逻辑
  1639. if (this.isEditingWork) {
  1640. this.workList[this.editingWorkIndex] = {...this.workForm};
  1641. uni.showToast({
  1642. title: '修改成功',
  1643. icon: 'success'
  1644. });
  1645. this.isEditingWork = false;
  1646. this.editingWorkIndex = -1;
  1647. } else {
  1648. this.workList.push({...this.workForm});
  1649. uni.showToast({
  1650. title: '添加成功',
  1651. icon: 'success'
  1652. });
  1653. }
  1654. // 重置表单
  1655. this.workForm = {
  1656. startTime: '',
  1657. endTime: '',
  1658. companyName: '',
  1659. department: '',
  1660. employeeCount: '',
  1661. position: '',
  1662. monthlySalary: '',
  1663. supervisor: '',
  1664. supervisorPhone: ''
  1665. };
  1666. },
  1667. editWork(index) {
  1668. this.isEditingWork = true;
  1669. this.editingWorkIndex = index;
  1670. this.workForm = {...this.workList[index]};
  1671. uni.pageScrollTo({
  1672. selector: '.work-form',
  1673. duration: 300
  1674. });
  1675. },
  1676. cancelEditWork() {
  1677. this.isEditingWork = false;
  1678. this.editingWorkIndex = -1;
  1679. this.workForm = {
  1680. startTime: '',
  1681. endTime: '',
  1682. companyName: '',
  1683. department: '',
  1684. employeeCount: '',
  1685. position: '',
  1686. monthlySalary: '',
  1687. supervisor: '',
  1688. supervisorPhone: ''
  1689. };
  1690. },
  1691. deleteWork(index) {
  1692. if (this.isEditingWork && this.editingWorkIndex === index) {
  1693. this.cancelEditWork();
  1694. }
  1695. this.workList.splice(index, 1);
  1696. uni.showToast({
  1697. title: '已删除',
  1698. icon: 'none'
  1699. });
  1700. },
  1701. submitForm() {
  1702. // 先验证当前步骤
  1703. if (!this.validateCurrentStep()) {
  1704. return;
  1705. }
  1706. // 在提交前检查并自动保存所有未保存的表单
  1707. this.autoSaveAllUnsavedForms();
  1708. // 验证所有必填字段
  1709. const allRequired = [
  1710. 'name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress'
  1711. ];
  1712. let isValid = true;
  1713. allRequired.forEach(field => {
  1714. // 只验证显示的字段
  1715. if (this.shouldValidateField(field) && !this.validateField(field, this.formData[field])) {
  1716. isValid = false;
  1717. }
  1718. });
  1719. // 验证专业技能和培训
  1720. if (this.shouldValidateField('skills') && !this.formData.skills?.trim()) {
  1721. this.formErrors.skills = '请描述您的专业技能';
  1722. isValid = false;
  1723. }
  1724. if (this.shouldValidateField('training') && !this.formData.training?.trim()) {
  1725. this.formErrors.training = '请描述您的培训经历';
  1726. isValid = false;
  1727. }
  1728. if (!isValid) {
  1729. uni.showToast({
  1730. title: '请完善所有必填信息',
  1731. icon: 'none'
  1732. });
  1733. return;
  1734. }
  1735. // 检查必要的用户信息
  1736. const userInfo = uni.getStorageSync('userInfo');
  1737. if (!userInfo) {
  1738. uni.showToast({
  1739. title: '用户信息获取失败,请重新登录',
  1740. icon: 'none',
  1741. duration: 2000
  1742. });
  1743. return;
  1744. }
  1745. try {
  1746. const userData = JSON.parse(userInfo);
  1747. const submitData = {
  1748. tenant_id: uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1,
  1749. user_id: userData.id,
  1750. personal_info: {
  1751. name: this.formData.name,
  1752. gender: this.formData.gender,
  1753. phone: this.formData.phone,
  1754. id_card: this.formData.idCard,
  1755. address: this.formData.currentAddress,
  1756. professional_skills: this.formData.skills ? this.formData.skills.split(',') : []
  1757. },
  1758. profile: {
  1759. female_status: this.getFemaleStatus(),
  1760. marital_status: this.getMaritalStatus(),
  1761. height: parseFloat(this.formData.height) || 0,
  1762. weight: parseFloat(this.formData.weight) || 0,
  1763. ethnicity: this.formData.ethnic,
  1764. current_address: this.formData.currentAddress,
  1765. expected_salary: parseFloat(this.formData.expectedSalary) || 0
  1766. },
  1767. educations: this.formatEducations(),
  1768. family_members: this.formatFamilyMembers(),
  1769. work_experiences: this.formatWorkExperiences()
  1770. };
  1771. // 数据检查
  1772. if (!submitData.personal_info.name || !submitData.personal_info.gender || !submitData.personal_info.phone) {
  1773. uni.showToast({
  1774. title: '基本信息不完整',
  1775. icon: 'none',
  1776. duration: 2000
  1777. });
  1778. return;
  1779. }
  1780. this.sendFormData(submitData);
  1781. } catch (error) {
  1782. console.error('数据处理错误:', error);
  1783. uni.showToast({
  1784. title: '数据处理错误,请重试',
  1785. icon: 'none',
  1786. duration: 2000
  1787. });
  1788. }
  1789. },
  1790. // 辅助方法:发送表单数据
  1791. sendFormData(submitData) {
  1792. uni.showLoading({ title: '提交中...' });
  1793. // 添加请求头和token
  1794. const token = uni.getStorageSync('token');
  1795. uni.request({
  1796. url: `${apiBaseUrl}/wechat/user/profile/update`,
  1797. method: 'POST',
  1798. data: submitData,
  1799. header: {
  1800. 'content-type': 'application/json',
  1801. 'Authorization': token ? `Bearer ${token}` : ''
  1802. },
  1803. success: (res) => {
  1804. uni.hideLoading();
  1805. if (res.statusCode === 200) {
  1806. if (res.data.code === 2000) {
  1807. uni.showToast({
  1808. title: '提交成功',
  1809. icon: 'success',
  1810. duration: 2000
  1811. });
  1812. uni.navigateTo({
  1813. url: '/pages/interview-notice/interview-notice'
  1814. });
  1815. } else {
  1816. uni.showToast({
  1817. title: res.data.msg || '提交失败',
  1818. icon: 'none',
  1819. duration: 2000
  1820. });
  1821. }
  1822. } else {
  1823. uni.showToast({
  1824. title: '服务器响应错误',
  1825. icon: 'none',
  1826. duration: 2000
  1827. });
  1828. }
  1829. },
  1830. fail: (err) => {
  1831. console.error('提交失败:', err);
  1832. uni.hideLoading();
  1833. // 检查具体错误类型
  1834. if (err.errMsg.includes('timeout')) {
  1835. uni.showToast({
  1836. title: '请求超时,请检查网络后重试',
  1837. icon: 'none',
  1838. duration: 2000
  1839. });
  1840. } else if (err.errMsg.includes('fail')) {
  1841. uni.showToast({
  1842. title: '网络连接失败,请检查网络设置',
  1843. icon: 'none',
  1844. duration: 2000
  1845. });
  1846. } else {
  1847. uni.showToast({
  1848. title: '提交失败,请稍后重试',
  1849. icon: 'none',
  1850. duration: 2000
  1851. });
  1852. }
  1853. },
  1854. complete: () => {
  1855. // 可以在这里添加完成后的处理逻辑
  1856. }
  1857. });
  1858. },
  1859. // 数据格式化方法
  1860. getFemaleStatus() {
  1861. if (this.formData.gender !== '女') return 0;
  1862. const statusMap = { '孕期': 1, '产期': 2, '哺乳期': 3 };
  1863. return statusMap[this.formData.threePeriod] || 0;
  1864. },
  1865. getMaritalStatus() {
  1866. const statusMap = { '未婚': 0, '已婚': 1, '离异': 2, '丧偶': 3 };
  1867. return statusMap[this.formData.marriage] || 0;
  1868. },
  1869. formatEducations() {
  1870. return this.educationList.map((edu, index) => ({
  1871. education_type: index === 0 ? 1 : 2,
  1872. degree: this.mapDegreeToNumber(edu.degree),
  1873. start_date: edu.startTime,
  1874. end_date: edu.endTime,
  1875. school_name: edu.schoolName,
  1876. major: edu.major
  1877. }));
  1878. },
  1879. formatFamilyMembers() {
  1880. return this.familyMembers.map(member => ({
  1881. relation: member.relation,
  1882. name: member.name,
  1883. workplace: member.workplaceOrAddress,
  1884. position: member.position,
  1885. phone: member.phone,
  1886. //is_emergency_contact: member.isEmergencyContact||false // 添加紧急联系人标识
  1887. }));
  1888. },
  1889. formatWorkExperiences() {
  1890. return this.workList.map(work => ({
  1891. start_date: work.startTime,
  1892. end_date: work.endTime,
  1893. company_name: work.companyName,
  1894. department: work.department,
  1895. company_size: parseInt(work.employeeCount)||0,
  1896. position: work.position,
  1897. monthly_salary: work.monthlySalary||0,
  1898. supervisor_name: work.supervisor,
  1899. supervisor_phone: work.supervisorPhone
  1900. }));
  1901. },
  1902. // 学历映射辅助方法
  1903. mapDegreeToNumber(degreeText) {
  1904. const degreeMap = {
  1905. '高中': 1,
  1906. '中专': 1,
  1907. '大专': 2,
  1908. '本科': 3,
  1909. '硕士': 4,
  1910. '博士': 5
  1911. };
  1912. return degreeMap[degreeText] || 6; // 默认为其他
  1913. },
  1914. prevStep() {
  1915. const prevIndex = this.currentStepIndex - 1;
  1916. if (prevIndex >= 0) {
  1917. let targetIndex = prevIndex;
  1918. // 检查上一步是否需要跳过
  1919. while (targetIndex >= 0) {
  1920. const stepId = this.steps[targetIndex].id;
  1921. // 如果是专业技能步骤且不需要显示,则跳过
  1922. if (stepId === 6 && !this.shouldShowSkillsStep) {
  1923. targetIndex--;
  1924. continue;
  1925. }
  1926. // 如果是教育经历步骤且不需要显示,则跳过
  1927. if (stepId === 5 && !this.shouldShowEducationStep) {
  1928. targetIndex--;
  1929. continue;
  1930. }
  1931. // 如果是家庭成员步骤且不需要显示,则跳过
  1932. if (stepId === 3 && !this.shouldShowFamilyStep) {
  1933. targetIndex--;
  1934. continue;
  1935. }
  1936. // 如果是工作经历步骤且不需要显示,则跳过
  1937. if (stepId === 8 && !this.shouldShowWorkStep) {
  1938. targetIndex--;
  1939. continue;
  1940. }
  1941. // 找到有效步骤,跳出循环
  1942. break;
  1943. }
  1944. // 如果找到有效步骤,跳转到该步骤
  1945. if (targetIndex >= 0) {
  1946. this.currentStep = this.steps[targetIndex].id;
  1947. }
  1948. // 滚动到页面顶部
  1949. uni.pageScrollTo({
  1950. scrollTop: 0,
  1951. duration: 300
  1952. });
  1953. }
  1954. },
  1955. nextStep() {
  1956. // 验证当前步骤
  1957. if (!this.validateCurrentStep()) {
  1958. return;
  1959. }
  1960. // 如果是第一步,需要进行身份验证
  1961. if (this.currentStep === 1) {
  1962. this.verifyIdentity();
  1963. return;
  1964. }
  1965. const nextIndex = this.currentStepIndex + 1;
  1966. if (nextIndex < this.steps.length) {
  1967. let targetIndex = nextIndex;
  1968. // 检查下一步是否需要跳过
  1969. while (targetIndex < this.steps.length) {
  1970. const stepId = this.steps[targetIndex].id;
  1971. console.log(this.steps[targetIndex].id)
  1972. // 如果是家庭成员步骤且不需要显示,则跳过
  1973. if (stepId === 3 && !this.shouldShowFamilyStep) {
  1974. targetIndex++;
  1975. continue;
  1976. }
  1977. // 如果是教育经历步骤且不需要显示,则跳过
  1978. if (stepId === 5 && !this.shouldShowEducationStep) {
  1979. targetIndex++;
  1980. continue;
  1981. }
  1982. // 如果是专业技能步骤且不需要显示,则跳过
  1983. if (stepId === 6 && !this.shouldShowSkillsStep) {
  1984. targetIndex++;
  1985. continue;
  1986. }
  1987. // 如果是工作经历步骤且不需要显示,则跳过
  1988. if (stepId === 8 && !this.shouldShowWorkStep) {
  1989. targetIndex++;
  1990. continue;
  1991. }
  1992. // 找到有效步骤,跳出循环
  1993. break;
  1994. }
  1995. // 如果找到有效步骤,跳转到该步骤
  1996. if (targetIndex < this.steps.length) {
  1997. this.currentStep = this.steps[targetIndex].id;
  1998. } else {
  1999. // 如果没有找到下一个有效步骤,说明当前步骤是最后一个需要显示的步骤
  2000. // 此时应该显示提交按钮,不需要跳转
  2001. console.log('当前步骤是最后一个需要显示的步骤,显示提交按钮');
  2002. }
  2003. // 滚动到页面顶部
  2004. uni.pageScrollTo({
  2005. scrollTop: 0,
  2006. duration: 300
  2007. });
  2008. }
  2009. },
  2010. // 身份验证方法
  2011. verifyIdentity() {
  2012. // 清空错误信息
  2013. this.formErrors = {
  2014. name: '',
  2015. idCard: '',
  2016. phone: ''
  2017. };
  2018. uni.showLoading({
  2019. title: '身份验证中...'
  2020. });
  2021. uni.request({
  2022. url: `${apiBaseUrl}/wechat/identity/verify`,
  2023. method: 'POST',
  2024. data: {
  2025. name: this.formData.name,
  2026. id_number: this.formData.idCard,
  2027. mobile: this.formData.phone
  2028. },
  2029. header: {
  2030. 'content-type': 'application/x-www-form-urlencoded'
  2031. },
  2032. success: (res) => {
  2033. uni.hideLoading();
  2034. console.log(res);
  2035. if (res.data.code === 200) {
  2036. // 验证通过,进入下一步
  2037. let targetIndex = this.currentStepIndex + 1;
  2038. // 跳过不需要显示的步骤(与 nextStep 保持一致)
  2039. while (targetIndex < this.steps.length) {
  2040. const stepId = this.steps[targetIndex].id;
  2041. if (stepId === 3 && !this.shouldShowFamilyStep) { targetIndex++; continue; }
  2042. if (stepId === 5 && !this.shouldShowEducationStep) { targetIndex++; continue; }
  2043. if (stepId === 6 && !this.shouldShowSkillsStep) { targetIndex++; continue; }
  2044. if (stepId === 8 && !this.shouldShowWorkStep) { targetIndex++; continue; }
  2045. break;
  2046. }
  2047. if (targetIndex < this.steps.length) {
  2048. this.currentStep = this.steps[targetIndex].id;
  2049. uni.pageScrollTo({ scrollTop: 0, duration: 300 });
  2050. } else {
  2051. // 如果没有找到下一个有效步骤,说明当前步骤是最后一个需要显示的步骤
  2052. // 此时应该显示提交按钮,不需要跳转
  2053. console.log('身份验证通过后,当前步骤是最后一个需要显示的步骤,显示提交按钮');
  2054. }
  2055. /* 保存姓名 */
  2056. this.setUserInfo(this.formData);
  2057. } else {
  2058. // 验证失败,显示错误信息
  2059. this.handleVerificationError(res.data);
  2060. }
  2061. },
  2062. fail: (err) => {
  2063. this.handleRequestError(err);
  2064. }
  2065. });
  2066. },
  2067. setUserInfo(data) {
  2068. uni.request({
  2069. url: `${apiBaseUrl}/wechat/updateUserInfo`,
  2070. method: 'POST',
  2071. data: {
  2072. openid: JSON.parse(uni.getStorageSync('userInfo')).openid,
  2073. name: data.name,
  2074. id_card: data.idCard,
  2075. purePhoneNumber: data.phone,
  2076. tenant_id:uni.getStorageSync('tenant_id') ||JSON.parse(uni.getStorageSync('userInfo')).tenant_id || 1,
  2077. examine:0
  2078. },
  2079. header: {
  2080. 'content-type': 'application/x-www-form-urlencoded'
  2081. },
  2082. success: (res) => {
  2083. console.log(res);
  2084. }
  2085. });
  2086. },
  2087. // 处理验证错误
  2088. handleVerificationError(data) {
  2089. this.formErrors.name = '姓名验证失败,请检查姓名是否正确';
  2090. this.formErrors.idCard = '身份证号验证失败,请检查身份证号是否正确';
  2091. this.formErrors.phone = '手机号验证失败,请检查手机号是否正确';
  2092. uni.showToast({
  2093. title: data.msg || '身份验证失败',
  2094. icon: 'none'
  2095. });
  2096. },
  2097. // 处理请求错误
  2098. handleRequestError(err) {
  2099. uni.hideLoading();
  2100. uni.showToast({
  2101. title: '网络错误,请检查网络连接',
  2102. icon: 'none',
  2103. duration: 2000
  2104. });
  2105. console.error('请求失败:', err);
  2106. },
  2107. // 验证当前步骤的必填项
  2108. validateCurrentStep() {
  2109. let isValid = true;
  2110. switch (this.currentStep) {
  2111. case 1: // 基本信息
  2112. const basicFields = ['name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress'];
  2113. basicFields.forEach(field => {
  2114. // 只验证显示的字段
  2115. if (this.shouldValidateField(field) && !this.validateField(field, this.formData[field])) {
  2116. isValid = false;
  2117. }
  2118. });
  2119. // 特殊验证:女性三期状态
  2120. if (this.shouldValidateField('threePeriod') && this.formData.gender === '女' && this.threePeriodIndex === -1) {
  2121. this.formErrors.threePeriod = '请选择三期状态';
  2122. isValid = false;
  2123. }
  2124. // 可选字段验证(如果有值则验证格式)
  2125. if (this.shouldValidateField('height') && this.formData.height) {
  2126. isValid = this.validateField('height', this.formData.height) && isValid;
  2127. }
  2128. if (this.shouldValidateField('weight') && this.formData.weight) {
  2129. isValid = this.validateField('weight', this.formData.weight) && isValid;
  2130. }
  2131. if (this.shouldValidateField('expectedSalary') && this.formData.expectedSalary) {
  2132. isValid = this.validateField('expectedSalary', this.formData.expectedSalary) && isValid;
  2133. }
  2134. break;
  2135. case 3: // 家庭成员
  2136. // 检查是否有未保存的家庭成员表单
  2137. if (this.hasUnsavedFamilyMemberForm()) {
  2138. // 尝试自动保存
  2139. if (!this.autoSaveFamilyMember()) {
  2140. isValid = false;
  2141. break;
  2142. }
  2143. }
  2144. console.log(this.familyMembers.length);
  2145. if (this.familyMembers.length == 0) {
  2146. uni.showToast({
  2147. title: '请至少添加一位家庭成员',
  2148. icon: 'none'
  2149. });
  2150. isValid = false;
  2151. }
  2152. break;
  2153. case 5: // 教育经历
  2154. // 检查是否有未保存的教育经历表单
  2155. if (this.hasUnsavedEducationForm()) {
  2156. // 尝试自动保存
  2157. if (!this.autoSaveEducation()) {
  2158. isValid = false;
  2159. break;
  2160. }
  2161. }
  2162. if (this.educationList.length === 0) {
  2163. uni.showToast({
  2164. title: '请至少添加一项教育经历',
  2165. icon: 'none'
  2166. });
  2167. isValid = false;
  2168. }
  2169. break;
  2170. case 6: // 专业技能
  2171. if (this.shouldValidateField('skills') && !this.formData.skills?.trim()) {
  2172. this.formErrors.skills = '请描述您的专业技能';
  2173. isValid = false;
  2174. }
  2175. if (this.shouldValidateField('training') && !this.formData.training?.trim()) {
  2176. this.formErrors.training = '请描述您的培训经历';
  2177. isValid = false;
  2178. }
  2179. break;
  2180. case 8: // 工作经历
  2181. // 检查是否有未保存的工作经历表单
  2182. if (this.hasUnsavedWorkForm()) {
  2183. // 尝试自动保存
  2184. if (!this.autoSaveWork()) {
  2185. isValid = false;
  2186. break;
  2187. }
  2188. }
  2189. if (this.workList.length === 0) {
  2190. uni.showToast({
  2191. title: '请至少添加一项工作经历',
  2192. icon: 'none'
  2193. });
  2194. isValid = false;
  2195. }
  2196. break;
  2197. }
  2198. /* if (!isValid) {
  2199. uni.showToast({
  2200. title: '请完善所有必填信息',
  2201. icon: 'none'
  2202. });
  2203. } */
  2204. return isValid;
  2205. },
  2206. // Add method to fetch user data
  2207. fetchUserData() {
  2208. this.isLoading = true;
  2209. // Get openid from storage
  2210. const userInfo = uni.getStorageSync('userInfo') ? JSON.parse(uni.getStorageSync('userInfo')) : {};
  2211. const openid = userInfo.openid;
  2212. if (!openid) {
  2213. uni.showToast({
  2214. title: '用户信息获取失败,请重新登录',
  2215. icon: 'none'
  2216. });
  2217. this.isLoading = false;
  2218. return;
  2219. }
  2220. uni.request({
  2221. url: `${apiBaseUrl}/api/wechat/user/get_full_info?tenant_id=${uni.getStorageSync('tenant_id') || JSON.parse(uni.getStorageSync('userInfo')).tenant_id ||1}&openid=${openid}`,
  2222. method: 'GET',
  2223. success: (res) => {
  2224. // 无论结果如何,都保持承诺书显示状态
  2225. this.showPromiseModal = true;
  2226. /* if (res.data.code === 2000) { */
  2227. // Successfully fetched data
  2228. this.populateFormData(res.data.data);
  2229. /* } else {
  2230. uni.showToast({
  2231. title: res.data.msg || '获取用户信息失败',
  2232. icon: 'none'
  2233. });
  2234. } */
  2235. },
  2236. fail: (err) => {
  2237. /* console.error('获取用户信息失败:', err);
  2238. uni.showToast({
  2239. title: '网络错误,请检查网络连接',
  2240. icon: 'none'
  2241. }); */
  2242. },
  2243. complete: () => {
  2244. this.isLoading = false;
  2245. // 数据加载完成后,检查当前步骤是否需要显示
  2246. this.$nextTick(() => {
  2247. this.ensureValidStep();
  2248. });
  2249. }
  2250. });
  2251. },
  2252. // Add method to populate form data with fetched data
  2253. populateFormData(data) {
  2254. const { user_info, profile, educations, work_experiences, family_members } = data;
  2255. // Populate basic user info
  2256. if (user_info) {
  2257. this.formData.name = user_info.name || '';
  2258. this.formData.gender = user_info.gender_text || '';
  2259. this.genderIndex = this.genderOptions.findIndex(item => item === this.formData.gender);
  2260. this.formData.idCard = user_info.id_card || '';
  2261. this.formData.phone = user_info.phone || '';
  2262. this.formData.email = user_info.email || '';
  2263. }
  2264. // Populate profile data
  2265. if (profile) {
  2266. // Set political status
  2267. this.formData.political = profile.political_status || '';
  2268. this.politicalIndex = this.politicalOptions.findIndex(item => item === this.formData.political);
  2269. // Set ethnic
  2270. this.formData.ethnic = profile.ethnicity || '';
  2271. this.ethnicIndex = this.ethnicOptions.findIndex(item => item === this.formData.ethnic);
  2272. // Set height and weight
  2273. this.formData.height = profile.height || '';
  2274. this.formData.weight = profile.weight || '';
  2275. // Set native place and residence
  2276. this.formData.nativePlace = profile.native_place || '';
  2277. this.formData.residence = profile.household_location || '';
  2278. // Set current address
  2279. this.formData.currentAddress = profile.current_address || '';
  2280. // Set marriage status
  2281. this.formData.marriage = profile.marital_status_text || '';
  2282. this.marriageIndex = this.marriageOptions.findIndex(item => item === this.formData.marriage);
  2283. // Set three period status for female
  2284. if (this.formData.gender === '女' && profile.female_status !== undefined) {
  2285. const femaleStatusMap = {0: '无', 1: '孕期', 2: '产期', 3: '哺乳期'};
  2286. this.formData.threePeriod = femaleStatusMap[profile.female_status] || '无';
  2287. this.threePeriodIndex = this.threePeriodOptions.findIndex(item => item === this.formData.threePeriod);
  2288. }
  2289. // Set expected salary
  2290. this.formData.expectedSalary = profile.expected_salary || '';
  2291. // Set emergency contact
  2292. this.formData.emergencyContact = profile.emergency_contact || '';
  2293. this.formData.emergencyPhone = profile.emergency_phone || '';
  2294. // Set hobby and motto
  2295. this.formData.hobby = profile.specialties || '';
  2296. this.formData.motto = profile.life_motto || '';
  2297. // Set recruitment source
  2298. const sourceTypeMap = {
  2299. 1: 'school',
  2300. 2: 'social',
  2301. 3: 'social',
  2302. 4: 'social',
  2303. 5: 'social'
  2304. };
  2305. const socialSourceMap = {
  2306. 2: 'BOSS',
  2307. 3: 'zhilian',
  2308. 4: 'liepin',
  2309. 5: 'other'
  2310. };
  2311. this.formData.sourceType = sourceTypeMap[profile.recruitment_source] || 'social';
  2312. if (this.formData.sourceType === 'social') {
  2313. this.formData.socialSource = socialSourceMap[profile.recruitment_source] || '';
  2314. if (this.formData.socialSource === 'other') {
  2315. this.formData.otherSocialSource = profile.recruitment_source_detail || '';
  2316. }
  2317. } else if (this.formData.sourceType === 'school') {
  2318. this.formData.otherSchoolSource = profile.recruitment_source_detail || '';
  2319. }
  2320. }
  2321. // Populate educations data
  2322. if (educations && educations.length > 0) {
  2323. this.educationList = educations.map(edu => {
  2324. const degreeMap = {
  2325. 1: '高中',
  2326. 2: '大专',
  2327. 3: '本科',
  2328. 4: '硕士',
  2329. 5: '博士'
  2330. };
  2331. return {
  2332. startTime: edu.start_date || '',
  2333. endTime: edu.end_date || '',
  2334. schoolName: edu.school_name || '',
  2335. major: edu.major || '',
  2336. degree: degreeMap[edu.degree] || ''
  2337. };
  2338. });
  2339. }
  2340. // Populate work experience data
  2341. if (work_experiences && work_experiences.length > 0) {
  2342. this.workList = work_experiences.map(work => {
  2343. return {
  2344. startTime: work.start_date || '',
  2345. endTime: work.end_date || '',
  2346. companyName: work.company_name || '',
  2347. department: work.department || '',
  2348. employeeCount: work.company_size || '',
  2349. position: work.position || '',
  2350. monthlySalary: work.monthly_salary || '',
  2351. supervisor: work.supervisor_name || '',
  2352. supervisorPhone: work.supervisor_phone || ''
  2353. };
  2354. });
  2355. }
  2356. // Populate family members data
  2357. if (family_members && family_members.length > 0) {
  2358. this.familyMembers = family_members.map(member => {
  2359. return {
  2360. relation: member.relation || '',
  2361. name: member.name || '',
  2362. workplaceOrAddress: member.workplace || '',
  2363. position: member.position || '',
  2364. phone: member.phone || '',
  2365. isEmergencyContact: member.isEmergencyContact || false
  2366. };
  2367. });
  2368. }
  2369. // 移除这段代码,确保承诺书始终显示
  2370. // if (user_info && user_info.is_profile_complete) {
  2371. // this.showPromiseModal = false;
  2372. // }
  2373. },
  2374. // 处理紧急联系人开关变化
  2375. handleEmergencyContactChange(e) {
  2376. this.familyMemberForm.isEmergencyContact = e.detail.value;
  2377. // 如果设置为紧急联系人,自动填充到紧急联系人字段
  2378. if (e.detail.value) {
  2379. this.formData.emergencyContact = this.familyMemberForm.name;
  2380. this.formData.emergencyPhone = this.familyMemberForm.phone;
  2381. }
  2382. },
  2383. // 添加重置教育经历错误信息的方法
  2384. resetEducationErrors() {
  2385. this.educationErrors = {
  2386. startTime: '',
  2387. endTime: '',
  2388. schoolName: '',
  2389. major: '',
  2390. degree: ''
  2391. };
  2392. },
  2393. // 添加通用验证方法
  2394. validateField(fieldName, value) {
  2395. const rule = this.validationRules[fieldName];
  2396. if (!rule) return true;
  2397. // 如果字段被隐藏,不进行验证
  2398. if (!this.shouldValidateField(fieldName)) {
  2399. return true;
  2400. }
  2401. // 重置该字段的错误信息
  2402. this.formErrors[fieldName] = '';
  2403. // 必填验证
  2404. if (rule.required && !value) {
  2405. this.formErrors[fieldName] = rule.message;
  2406. return false;
  2407. }
  2408. // 正则验证
  2409. if (rule.pattern && value && !rule.pattern.test(value)) {
  2410. this.formErrors[fieldName] = rule.message;
  2411. return false;
  2412. }
  2413. return true;
  2414. },
  2415. validateExpectedSalary(e) {
  2416. const value = e.detail.value;
  2417. console.log(value);
  2418. if (value === '') {
  2419. this.formData.expectedSalary = '';
  2420. this.formErrors.expectedSalary = '';
  2421. return;
  2422. }
  2423. let num = parseFloat(value);
  2424. if (isNaN(num)) {
  2425. this.formErrors.expectedSalary = '请输入有效的数字';
  2426. return;
  2427. }
  2428. if (num < 0) {
  2429. num = 0;
  2430. this.formErrors.expectedSalary = '薪资不能小于0';
  2431. } else if (num > 100000) {
  2432. num = 100000;
  2433. this.formErrors.expectedSalary = '薪资不能超过100000';
  2434. }
  2435. this.formData.expectedSalary = num.toString();
  2436. },
  2437. validateEmployeeCount(e) {
  2438. const value = e.detail.value;
  2439. if (value === '') {
  2440. this.workForm.employeeCount = '';
  2441. this.workErrors.employeeCount = '';
  2442. return;
  2443. }
  2444. let num = parseInt(value);
  2445. if (isNaN(num)) {
  2446. this.workErrors.employeeCount = '请输入有效的数字';
  2447. return;
  2448. }
  2449. if (num < 0) {
  2450. num = 0;
  2451. this.workErrors.employeeCount = '人数不能小于0';
  2452. } else if (num > 10000) {
  2453. num = 10000;
  2454. this.workErrors.employeeCount = '人数不能超过10000';
  2455. }
  2456. this.workForm.employeeCount = num.toString();
  2457. },
  2458. validateMonthlySalary(e) {
  2459. const value = e.detail.value;
  2460. if (value === '') {
  2461. this.workForm.monthlySalary = '';
  2462. this.workErrors.monthlySalary = '';
  2463. return;
  2464. }
  2465. let num = parseInt(value);
  2466. if (isNaN(num)) {
  2467. this.workErrors.monthlySalary = '请输入有效的数字';
  2468. return;
  2469. }
  2470. if (num < 0) {
  2471. num = 0;
  2472. this.workErrors.monthlySalary = '月总收入不能小于0';
  2473. } else if (num > 100000) {
  2474. num = 100000;
  2475. this.workErrors.monthlySalary = '月总收入不能超过100000';
  2476. } else {
  2477. this.workErrors.monthlySalary = '';
  2478. }
  2479. this.workForm.monthlySalary = num.toString();
  2480. },
  2481. // 添加手机号验证方法
  2482. validatePhone(e) {
  2483. const value = e.detail.value;
  2484. if (value.length > 11) {
  2485. this.formData.phone = value.slice(0, 11);
  2486. }
  2487. // 实时验证手机号格式
  2488. if (value && !/^1[3-9]\d{0,9}$/.test(value)) {
  2489. this.formErrors.phone = '请输入正确的手机号码';
  2490. } else {
  2491. this.formErrors.phone = '';
  2492. }
  2493. },
  2494. // 检查是否有未保存的家庭成员表单
  2495. hasUnsavedFamilyMemberForm() {
  2496. return this.familyMemberForm.relation ||
  2497. this.familyMemberForm.name ||
  2498. this.familyMemberForm.workplaceOrAddress ||
  2499. this.familyMemberForm.position ||
  2500. this.familyMemberForm.phone;
  2501. },
  2502. // 检查是否有未保存的教育经历表单
  2503. hasUnsavedEducationForm() {
  2504. return this.educationForm.startTime ||
  2505. this.educationForm.endTime ||
  2506. this.educationForm.schoolName ||
  2507. this.educationForm.major ||
  2508. this.educationForm.degree;
  2509. },
  2510. // 检查是否有未保存的工作经历表单
  2511. hasUnsavedWorkForm() {
  2512. return this.workForm.startTime ||
  2513. this.workForm.endTime ||
  2514. this.workForm.companyName ||
  2515. this.workForm.department ||
  2516. this.workForm.position ||
  2517. this.workForm.employeeCount ||
  2518. this.workForm.monthlySalary ||
  2519. this.workForm.supervisor ||
  2520. this.workForm.supervisorPhone;
  2521. },
  2522. // 自动保存家庭成员
  2523. autoSaveFamilyMember() {
  2524. // 重置错误信息
  2525. this.resetFamilyMemberErrors();
  2526. // 验证必填字段
  2527. let isValid = true;
  2528. // 只验证显示的字段
  2529. if (this.shouldValidateField('relation', 'family') && !this.familyMemberForm.relation) {
  2530. this.familyMemberErrors.relation = '请输入称谓';
  2531. isValid = false;
  2532. }
  2533. if (this.shouldValidateField('name', 'family') && !this.familyMemberForm.name) {
  2534. this.familyMemberErrors.name = '请输入姓名';
  2535. isValid = false;
  2536. }
  2537. if (!isValid) {
  2538. uni.showToast({
  2539. title: '请完善家庭成员必填信息',
  2540. icon: 'none'
  2541. });
  2542. return false;
  2543. }
  2544. // 自动保存逻辑
  2545. if (this.isEditing) {
  2546. this.familyMembers[this.editingIndex] = {...this.familyMemberForm};
  2547. this.isEditing = false;
  2548. this.editingIndex = -1;
  2549. } else {
  2550. this.familyMembers.push({...this.familyMemberForm});
  2551. }
  2552. // 重置表单
  2553. this.resetFamilyMemberForm();
  2554. uni.showToast({
  2555. title: '已自动保存',
  2556. icon: 'success',
  2557. duration: 1500
  2558. });
  2559. return true;
  2560. },
  2561. // 自动保存教育经历
  2562. autoSaveEducation() {
  2563. // 重置错误信息
  2564. this.resetEducationErrors();
  2565. // 验证必填字段
  2566. let isValid = true;
  2567. // 只验证显示的字段
  2568. if (this.shouldValidateField('startTime', 'education') && !this.educationForm.startTime) {
  2569. this.educationErrors.startTime = '请选择开始时间';
  2570. isValid = false;
  2571. }
  2572. if (this.shouldValidateField('endTime', 'education') && !this.educationForm.endTime) {
  2573. this.educationErrors.endTime = '请选择结束时间';
  2574. isValid = false;
  2575. }
  2576. if (this.shouldValidateField('schoolName', 'education') && !this.educationForm.schoolName) {
  2577. this.educationErrors.schoolName = '请输入学校名称';
  2578. isValid = false;
  2579. }
  2580. if (this.shouldValidateField('major', 'education') && !this.educationForm.major) {
  2581. this.educationErrors.major = '请输入专业';
  2582. isValid = false;
  2583. }
  2584. if (this.shouldValidateField('degree', 'education') && !this.educationForm.degree) {
  2585. this.educationErrors.degree = '请选择学历';
  2586. isValid = false;
  2587. }
  2588. if (!isValid) {
  2589. uni.showToast({
  2590. title: '请完善教育经历必填信息',
  2591. icon: 'none'
  2592. });
  2593. return false;
  2594. }
  2595. // 自动保存逻辑
  2596. if (this.isEditingEducation) {
  2597. this.educationList[this.editingEducationIndex] = {...this.educationForm};
  2598. this.isEditingEducation = false;
  2599. this.editingEducationIndex = -1;
  2600. } else {
  2601. this.educationList.push({...this.educationForm});
  2602. }
  2603. // 重置表单
  2604. this.educationForm = {
  2605. startTime: '',
  2606. endTime: '',
  2607. schoolName: '',
  2608. major: '',
  2609. degree: ''
  2610. };
  2611. this.degreeIndex = -1;
  2612. uni.showToast({
  2613. title: '已自动保存',
  2614. icon: 'success',
  2615. duration: 1500
  2616. });
  2617. return true;
  2618. },
  2619. // 自动保存工作经历
  2620. autoSaveWork() {
  2621. // 重置所有工作经历相关的错误信息
  2622. this.workErrors = {
  2623. startTime: '',
  2624. endTime: '',
  2625. companyName: '',
  2626. department: '',
  2627. position: '',
  2628. employeeCount: '',
  2629. monthlySalary: '',
  2630. supervisor: '',
  2631. supervisorPhone: ''
  2632. };
  2633. // 验证必填字段
  2634. let isValid = true;
  2635. // 只验证显示的字段
  2636. if (this.shouldValidateField('startTime', 'work') && !this.workForm.startTime) {
  2637. this.workErrors.startTime = '请选择开始时间';
  2638. isValid = false;
  2639. }
  2640. if (this.shouldValidateField('endTime', 'work') && !this.workForm.endTime) {
  2641. this.workErrors.endTime = '请选择结束时间';
  2642. isValid = false;
  2643. }
  2644. if (this.shouldValidateField('companyName', 'work') && !this.workForm.companyName) {
  2645. this.workErrors.companyName = '请输入单位名称';
  2646. isValid = false;
  2647. }
  2648. if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
  2649. this.workErrors.employeeCount = '请输入单位人数';
  2650. isValid = false;
  2651. }
  2652. if (this.shouldValidateField('department', 'work') && !this.workForm.department) {
  2653. this.workErrors.department = '请输入任职部门';
  2654. isValid = false;
  2655. }
  2656. if (this.shouldValidateField('position', 'work') && !this.workForm.position) {
  2657. this.workErrors.position = '请输入担任职务';
  2658. isValid = false;
  2659. }
  2660. if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
  2661. this.workErrors.employeeCount = '请输入单位人数';
  2662. isValid = false;
  2663. }
  2664. if (this.shouldValidateField('monthlySalary', 'work') && !this.workForm.monthlySalary) {
  2665. this.workErrors.monthlySalary = '请输入月总收入';
  2666. isValid = false;
  2667. }
  2668. if (!isValid) {
  2669. uni.showToast({
  2670. title: '请完善工作经历必填信息',
  2671. icon: 'none'
  2672. });
  2673. return false;
  2674. }
  2675. // 自动保存逻辑
  2676. if (this.isEditingWork) {
  2677. this.workList[this.editingWorkIndex] = {...this.workForm};
  2678. this.isEditingWork = false;
  2679. this.editingWorkIndex = -1;
  2680. } else {
  2681. this.workList.push({...this.workForm});
  2682. }
  2683. // 重置表单
  2684. this.workForm = {
  2685. startTime: '',
  2686. endTime: '',
  2687. companyName: '',
  2688. department: '',
  2689. employeeCount: '',
  2690. position: '',
  2691. monthlySalary: '',
  2692. supervisor: '',
  2693. supervisorPhone: ''
  2694. };
  2695. uni.showToast({
  2696. title: '已自动保存',
  2697. icon: 'success',
  2698. duration: 1500
  2699. });
  2700. return true;
  2701. },
  2702. // 自动保存所有未保存的表单
  2703. autoSaveAllUnsavedForms() {
  2704. // 检查并自动保存家庭成员表单
  2705. if (this.hasUnsavedFamilyMemberForm()) {
  2706. this.autoSaveFamilyMember();
  2707. }
  2708. // 检查并自动保存教育经历表单
  2709. if (this.hasUnsavedEducationForm()) {
  2710. this.autoSaveEducation();
  2711. }
  2712. // 检查并自动保存工作经历表单
  2713. if (this.hasUnsavedWorkForm()) {
  2714. this.autoSaveWork();
  2715. }
  2716. }
  2717. },
  2718. // 添加监听器来清除错误信息
  2719. watch: {
  2720. 'formData.name': function(newVal) {
  2721. if (newVal && this.formErrors.name) {
  2722. this.formErrors.name = '';
  2723. }
  2724. },
  2725. 'formData.idCard': function(newVal) {
  2726. if (newVal && this.formErrors.idCard) {
  2727. this.formErrors.idCard = '';
  2728. }
  2729. },
  2730. 'formData.phone': function(newVal) {
  2731. if (newVal && this.formErrors.phone) {
  2732. this.formErrors.phone = '';
  2733. }
  2734. },
  2735. 'formData.gender': function(newVal) {
  2736. if (newVal && this.formErrors.gender) {
  2737. this.formErrors.gender = '';
  2738. }
  2739. },
  2740. 'formData.ethnic': function(newVal) {
  2741. if (newVal && this.formErrors.ethnic) {
  2742. this.formErrors.ethnic = '';
  2743. }
  2744. },
  2745. 'formData.currentAddress': function(newVal) {
  2746. if (newVal && this.formErrors.currentAddress) {
  2747. this.formErrors.currentAddress = '';
  2748. }
  2749. },
  2750. 'formData.height': function(newVal) {
  2751. if (newVal && this.formErrors.height) {
  2752. this.formErrors.height = '';
  2753. }
  2754. },
  2755. 'formData.weight': function(newVal) {
  2756. if (newVal && this.formErrors.weight) {
  2757. this.formErrors.weight = '';
  2758. }
  2759. },
  2760. 'formData.expectedSalary': function(newVal) {
  2761. if (newVal && this.formErrors.expectedSalary) {
  2762. this.formErrors.expectedSalary = '';
  2763. }
  2764. },
  2765. 'familyMemberForm.relation': function(newVal) {
  2766. if (newVal) this.familyMemberErrors.relation = '';
  2767. },
  2768. 'familyMemberForm.name': function(newVal) {
  2769. if (newVal) this.familyMemberErrors.name = '';
  2770. },
  2771. 'familyMemberForm.phone': function(newVal) {
  2772. if (newVal) this.familyMemberErrors.phone = '';
  2773. },
  2774. /* 'familyMemberForm.workplaceOrAddress': function(newVal) {
  2775. if (newVal) this.familyMemberErrors.workplaceOrAddress = '';
  2776. },
  2777. 'familyMemberForm.position': function(newVal) {
  2778. if (newVal) this.familyMemberErrors.position = '';
  2779. }, */
  2780. 'workForm.companyName': function(newVal) {
  2781. if (newVal && this.workErrors.companyName) {
  2782. this.workErrors.companyName = '';
  2783. }
  2784. },
  2785. 'workForm.department': function(newVal) {
  2786. if (newVal && this.workErrors.department) {
  2787. this.workErrors.department = '';
  2788. }
  2789. },
  2790. 'workForm.position': function(newVal) {
  2791. if (newVal && this.workErrors.position) {
  2792. this.workErrors.position = '';
  2793. }
  2794. },
  2795. 'workForm.employeeCount': function(newVal) {
  2796. if (newVal && this.workErrors.employeeCount) {
  2797. this.workErrors.employeeCount = '';
  2798. }
  2799. },
  2800. 'workForm.monthlySalary': function(newVal) {
  2801. if (newVal && this.workErrors.monthlySalary) {
  2802. this.workErrors.monthlySalary = '';
  2803. }
  2804. },
  2805. 'workForm.supervisor': function(newVal) {
  2806. if (newVal && this.workErrors.supervisor) {
  2807. this.workErrors.supervisor = '';
  2808. }
  2809. },
  2810. // 'workForm.supervisorPhone': function(newVal) {
  2811. // if (newVal && this.workErrors.supervisorPhone) {
  2812. // this.workErrors.supervisorPhone = '';
  2813. // }
  2814. // },
  2815. 'formData.training': function(newVal) {
  2816. if (newVal && this.formErrors.training) {
  2817. this.formErrors.training = '';
  2818. }
  2819. },
  2820. 'educationForm.startTime': function(newVal) {
  2821. if (newVal) this.educationErrors.startTime = '';
  2822. },
  2823. 'educationForm.endTime': function(newVal) {
  2824. if (newVal) this.educationErrors.endTime = '';
  2825. },
  2826. 'educationForm.schoolName': function(newVal) {
  2827. if (newVal) this.educationErrors.schoolName = '';
  2828. },
  2829. 'educationForm.major': function(newVal) {
  2830. if (newVal) this.educationErrors.major = '';
  2831. },
  2832. 'educationForm.degree': function(newVal) {
  2833. if (newVal) this.educationErrors.degree = '';
  2834. },
  2835. // 添加对表单字段的实时验证
  2836. 'formData': {
  2837. handler(newVal) {
  2838. // 只验证当前步骤的字段
  2839. const currentStepFields = {
  2840. 1: ['name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress', 'height', 'weight', 'expectedSalary'],
  2841. 6: ['skills', 'training']
  2842. }[this.currentStep];
  2843. if (currentStepFields) {
  2844. currentStepFields.forEach(field => {
  2845. if (newVal[field] !== undefined && this.shouldValidateField(field)) {
  2846. this.validateField(field, newVal[field]);
  2847. }
  2848. });
  2849. }
  2850. },
  2851. deep: true
  2852. }
  2853. },
  2854. }
  2855. </script>
  2856. <style>
  2857. .personal-container {
  2858. padding: 20rpx;
  2859. }
  2860. .form-title {
  2861. font-size: 36rpx;
  2862. font-weight: bold;
  2863. text-align: center;
  2864. margin-bottom: 30rpx;
  2865. }
  2866. .form-container {
  2867. background-color: #fff;
  2868. border-radius: 10rpx;
  2869. padding: 20rpx;
  2870. }
  2871. .section-title {
  2872. font-size: 32rpx;
  2873. font-weight: bold;
  2874. margin: 30rpx 0 20rpx 10rpx;
  2875. color: #333;
  2876. border-left: 4rpx solid #0039b3;
  2877. padding-left: 15rpx;
  2878. }
  2879. .form-row {
  2880. display: flex;
  2881. flex-direction: row;
  2882. margin-bottom: 20rpx;
  2883. flex-wrap: wrap;
  2884. }
  2885. .form-item {
  2886. flex: 1;
  2887. min-width: 300rpx;
  2888. margin: 10rpx;
  2889. border-bottom: 1px solid #eee;
  2890. padding-bottom: 10rpx;
  2891. }
  2892. .label {
  2893. font-size: 28rpx;
  2894. color: #333;
  2895. margin-right: 10rpx;
  2896. display: block;
  2897. margin-bottom: 10rpx;
  2898. position: relative;
  2899. padding-left: 14rpx; /* 为星号预留空间 */
  2900. }
  2901. input {
  2902. font-size: 28rpx;
  2903. height: 60rpx;
  2904. }
  2905. .picker-text {
  2906. font-size: 28rpx;
  2907. height: 60rpx;
  2908. line-height: 60rpx;
  2909. color: #666;
  2910. }
  2911. .submit-btn {
  2912. margin-top: 40rpx;
  2913. background-color: #0039b3;
  2914. color: #fff;
  2915. }
  2916. .family-members-list {
  2917. margin-top: 20rpx;
  2918. }
  2919. .family-member-item {
  2920. background-color: #f8f8f8;
  2921. border-radius: 8rpx;
  2922. padding: 20rpx;
  2923. margin-bottom: 20rpx;
  2924. }
  2925. .family-member-header {
  2926. display: flex;
  2927. justify-content: space-between;
  2928. align-items: center;
  2929. margin-bottom: 15rpx;
  2930. border-bottom: 1px solid #eee;
  2931. padding-bottom: 10rpx;
  2932. }
  2933. .family-member-title {
  2934. font-size: 30rpx;
  2935. font-weight: bold;
  2936. color: #333;
  2937. }
  2938. .family-member-actions {
  2939. display: flex;
  2940. gap: 20rpx;
  2941. }
  2942. .family-member-edit {
  2943. font-size: 26rpx;
  2944. color: #1890ff;
  2945. }
  2946. .family-member-delete {
  2947. font-size: 26rpx;
  2948. color: #ff4d4f;
  2949. }
  2950. .form-subtitle {
  2951. font-size: 28rpx;
  2952. font-weight: bold;
  2953. margin-bottom: 20rpx;
  2954. display: flex;
  2955. justify-content: space-between;
  2956. align-items: center;
  2957. }
  2958. .cancel-edit {
  2959. font-size: 26rpx;
  2960. color: #999;
  2961. font-weight: normal;
  2962. }
  2963. .family-member-content {
  2964. padding: 10rpx 0;
  2965. }
  2966. .family-member-row {
  2967. display: flex;
  2968. margin-bottom: 10rpx;
  2969. }
  2970. .family-member-label {
  2971. font-size: 26rpx;
  2972. color: #666;
  2973. width: 200rpx;
  2974. }
  2975. .family-member-value {
  2976. font-size: 26rpx;
  2977. color: #333;
  2978. flex: 1;
  2979. }
  2980. .family-member-form {
  2981. background-color: #fff;
  2982. border-radius: 8rpx;
  2983. padding: 20rpx;
  2984. margin-top: 20rpx;
  2985. }
  2986. .form-row button-row {
  2987. display: flex;
  2988. justify-content: center;
  2989. margin-top: 20rpx;
  2990. }
  2991. .form-item button-container {
  2992. display: flex;
  2993. flex-direction: column;
  2994. align-items: center;
  2995. }
  2996. .circle-btn {
  2997. width: 40rpx;
  2998. height: 40rpx;
  2999. border-radius: 50%;
  3000. background-color: #0039b3;
  3001. display: flex;
  3002. justify-content: center;
  3003. align-items: center;
  3004. margin-bottom: 10rpx;
  3005. }
  3006. .btn-icon {
  3007. font-size: 32rpx;
  3008. color: #fff;
  3009. }
  3010. .btn-text {
  3011. font-size: 28rpx;
  3012. color: #333;
  3013. }
  3014. /* 添加圆形按钮相关样式 */
  3015. .button-row {
  3016. justify-content: center;
  3017. margin-top: 30rpx;
  3018. }
  3019. .button-container {
  3020. display: flex;
  3021. flex-direction: column;
  3022. align-items: center;
  3023. border-bottom: none;
  3024. min-width: auto;
  3025. }
  3026. .circle-btn {
  3027. width: 100rpx;
  3028. height: 100rpx;
  3029. border-radius: 50%;
  3030. padding: 0;
  3031. display: flex;
  3032. align-items: center;
  3033. justify-content: center;
  3034. background-color: #0039b3;
  3035. box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.1);
  3036. margin: 0;
  3037. }
  3038. .btn-icon {
  3039. font-size: 50rpx;
  3040. color: #fff;
  3041. line-height: 1;
  3042. }
  3043. .btn-text {
  3044. font-size: 24rpx;
  3045. color: #666;
  3046. margin-top: 10rpx;
  3047. }
  3048. /* 编辑状态下的按钮颜色 */
  3049. .circle-btn.editing {
  3050. background-color: #1890ff;
  3051. }
  3052. /* 移除原来的添加按钮样式 */
  3053. .add-member-btn {
  3054. display: none;
  3055. }
  3056. /* 应聘来源样式 */
  3057. .source-container {
  3058. background-color: #fff;
  3059. border-radius: 10rpx;
  3060. padding: 20rpx;
  3061. margin-bottom: 30rpx;
  3062. }
  3063. .source-row {
  3064. display: flex;
  3065. margin-bottom: 20rpx;
  3066. align-items: flex-start;
  3067. }
  3068. .source-label {
  3069. width: 120rpx;
  3070. font-size: 28rpx;
  3071. color: #333;
  3072. padding-top: 6rpx;
  3073. }
  3074. .source-options {
  3075. flex: 1;
  3076. display: flex;
  3077. flex-wrap: wrap;
  3078. }
  3079. .source-option {
  3080. display: flex;
  3081. align-items: center;
  3082. margin-right: 30rpx;
  3083. margin-bottom: 15rpx;
  3084. }
  3085. .source-option text {
  3086. font-size: 28rpx;
  3087. margin-left: 8rpx;
  3088. }
  3089. .other-option {
  3090. flex-basis: 100%;
  3091. margin-top: 10rpx;
  3092. }
  3093. .other-option input {
  3094. border-bottom: 1px solid #eee;
  3095. width: 300rpx;
  3096. margin-left: 10rpx;
  3097. font-size: 28rpx;
  3098. }
  3099. /* 教育经历样式 */
  3100. .education-list {
  3101. margin-top: 20rpx;
  3102. }
  3103. .education-item {
  3104. background-color: #f8f8f8;
  3105. border-radius: 8rpx;
  3106. padding: 20rpx;
  3107. margin-bottom: 20rpx;
  3108. }
  3109. .education-header {
  3110. display: flex;
  3111. justify-content: space-between;
  3112. align-items: center;
  3113. margin-bottom: 15rpx;
  3114. border-bottom: 1px solid #eee;
  3115. padding-bottom: 10rpx;
  3116. }
  3117. .education-title {
  3118. font-size: 30rpx;
  3119. font-weight: bold;
  3120. color: #333;
  3121. }
  3122. .education-actions {
  3123. display: flex;
  3124. gap: 20rpx;
  3125. }
  3126. .education-edit {
  3127. font-size: 26rpx;
  3128. color: #1890ff;
  3129. }
  3130. .education-delete {
  3131. font-size: 26rpx;
  3132. color: #ff4d4f;
  3133. }
  3134. .education-content {
  3135. padding: 10rpx 0;
  3136. }
  3137. .education-row {
  3138. display: flex;
  3139. margin-bottom: 10rpx;
  3140. }
  3141. .education-label {
  3142. font-size: 26rpx;
  3143. color: #666;
  3144. width: 150rpx;
  3145. }
  3146. .education-value {
  3147. font-size: 26rpx;
  3148. color: #333;
  3149. flex: 1;
  3150. }
  3151. .education-form {
  3152. background-color: #fff;
  3153. border-radius: 8rpx;
  3154. padding: 20rpx;
  3155. margin-top: 20rpx;
  3156. }
  3157. .date-range {
  3158. display: flex;
  3159. align-items: center;
  3160. justify-content: space-around;
  3161. }
  3162. .date-separator {
  3163. margin: 0 10rpx;
  3164. color: #666;
  3165. }
  3166. /* 专业技能和培训样式 */
  3167. .skills-container, .training-container {
  3168. background-color: #fff;
  3169. border-radius: 10rpx;
  3170. padding: 20rpx;
  3171. margin-bottom: 20rpx;
  3172. }
  3173. .skills-textarea, .training-textarea {
  3174. width: 100%;
  3175. height: 200rpx;
  3176. font-size: 28rpx;
  3177. line-height: 1.5;
  3178. padding: 10rpx;
  3179. box-sizing: border-box;
  3180. border: 1px solid #eee;
  3181. border-radius: 6rpx;
  3182. }
  3183. /* 工作经历样式 */
  3184. .work-list {
  3185. margin-top: 20rpx;
  3186. }
  3187. .work-item {
  3188. background-color: #f8f8f8;
  3189. border-radius: 8rpx;
  3190. padding: 20rpx;
  3191. margin-bottom: 20rpx;
  3192. }
  3193. .work-header {
  3194. display: flex;
  3195. justify-content: space-between;
  3196. align-items: center;
  3197. margin-bottom: 15rpx;
  3198. border-bottom: 1px solid #eee;
  3199. padding-bottom: 10rpx;
  3200. }
  3201. .work-title {
  3202. font-size: 30rpx;
  3203. font-weight: bold;
  3204. color: #333;
  3205. }
  3206. .work-actions {
  3207. display: flex;
  3208. gap: 20rpx;
  3209. }
  3210. .work-edit {
  3211. font-size: 26rpx;
  3212. color: #1890ff;
  3213. }
  3214. .work-delete {
  3215. font-size: 26rpx;
  3216. color: #ff4d4f;
  3217. }
  3218. .work-content {
  3219. padding: 10rpx 0;
  3220. }
  3221. .work-row {
  3222. display: flex;
  3223. margin-bottom: 10rpx;
  3224. }
  3225. .work-label {
  3226. font-size: 26rpx;
  3227. color: #666;
  3228. width: 150rpx;
  3229. }
  3230. .work-value {
  3231. font-size: 26rpx;
  3232. color: #333;
  3233. flex: 1;
  3234. }
  3235. .work-form {
  3236. background-color: #fff;
  3237. border-radius: 8rpx;
  3238. padding: 20rpx;
  3239. margin-top: 20rpx;
  3240. }
  3241. /* 步骤指示器样式 */
  3242. .steps-indicator {
  3243. display: flex;
  3244. justify-content: space-between;
  3245. margin-bottom: 30rpx;
  3246. padding: 20rpx;
  3247. background-color: #fff;
  3248. border-radius: 10rpx;
  3249. overflow-x: auto;
  3250. }
  3251. .step-item {
  3252. display: flex;
  3253. flex-direction: column;
  3254. align-items: center;
  3255. position: relative;
  3256. min-width: 120rpx;
  3257. }
  3258. .step-item:not(:last-child)::after {
  3259. content: '';
  3260. position: absolute;
  3261. top: 20rpx;
  3262. right: -50%;
  3263. width: 100%;
  3264. height: 2rpx;
  3265. background-color: #ddd;
  3266. z-index: 1;
  3267. }
  3268. .step-item.active:not(:last-child)::after {
  3269. background-color: #0039b3;
  3270. }
  3271. .step-number {
  3272. width: 40rpx;
  3273. height: 40rpx;
  3274. border-radius: 50%;
  3275. background-color: #ddd;
  3276. color: #fff;
  3277. display: flex;
  3278. justify-content: center;
  3279. align-items: center;
  3280. font-size: 24rpx;
  3281. margin-bottom: 10rpx;
  3282. position: relative;
  3283. z-index: 2;
  3284. }
  3285. .step-item.active .step-number {
  3286. background-color: #0039b3;
  3287. }
  3288. .step-item.current .step-number {
  3289. background-color: #0039b3;
  3290. box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.2);
  3291. }
  3292. .step-name {
  3293. font-size: 22rpx;
  3294. color: #999;
  3295. text-align: center;
  3296. }
  3297. .step-item.active .step-name {
  3298. color: #333;
  3299. }
  3300. .step-item.current .step-name {
  3301. color: #0039b3;
  3302. font-weight: bold;
  3303. }
  3304. /* 导航按钮样式 */
  3305. .nav-buttons {
  3306. display: flex;
  3307. justify-content: space-between;
  3308. margin-top: 40rpx;
  3309. padding: 0 20rpx;
  3310. }
  3311. .nav-btn {
  3312. flex: 1;
  3313. margin: 0 10rpx;
  3314. height: 80rpx;
  3315. line-height: 80rpx;
  3316. text-align: center;
  3317. border-radius: 40rpx;
  3318. font-size: 28rpx;
  3319. }
  3320. .prev-btn {
  3321. background-color: #f0f0f0;
  3322. color: #666;
  3323. }
  3324. .next-btn {
  3325. background-color: #0039b3;
  3326. color: #fff;
  3327. }
  3328. .submit-btn {
  3329. flex: 1;
  3330. margin: 0 10rpx;
  3331. height: 80rpx;
  3332. line-height: 80rpx;
  3333. text-align: center;
  3334. border-radius: 40rpx;
  3335. font-size: 28rpx;
  3336. background-color: #0039b3;
  3337. color: #fff;
  3338. }
  3339. /* 确认提交页样式 */
  3340. .confirm-container {
  3341. background-color: #fff;
  3342. border-radius: 10rpx;
  3343. padding: 20rpx;
  3344. margin-bottom: 30rpx;
  3345. }
  3346. .confirm-message {
  3347. padding: 20rpx;
  3348. background-color: #f6f6f6;
  3349. border-radius: 8rpx;
  3350. margin-bottom: 20rpx;
  3351. }
  3352. .info-summary {
  3353. padding: 20rpx;
  3354. }
  3355. .summary-item {
  3356. display: flex;
  3357. margin-bottom: 15rpx;
  3358. }
  3359. .summary-label {
  3360. width: 150rpx;
  3361. font-size: 28rpx;
  3362. color: #666;
  3363. }
  3364. .summary-value {
  3365. flex: 1;
  3366. font-size: 28rpx;
  3367. color: #333;
  3368. }
  3369. .input-error {
  3370. border-bottom: 1px solid #ff4d4f !important;
  3371. }
  3372. .error-message {
  3373. color: #ff4d4f;
  3374. font-size: 24rpx;
  3375. margin-top: 6rpx;
  3376. display: block;
  3377. }
  3378. /* 添加承诺书弹框样式 */
  3379. .promise-modal {
  3380. position: fixed;
  3381. top: 0;
  3382. left: 0;
  3383. right: 0;
  3384. bottom: 0;
  3385. background-color: rgba(0, 0, 0, 0.5);
  3386. z-index: 999;
  3387. display: flex;
  3388. justify-content: center;
  3389. align-items: center;
  3390. }
  3391. .promise-content {
  3392. width: 80%;
  3393. max-width: 600rpx;
  3394. background-color: #fff;
  3395. border-radius: 12rpx;
  3396. padding: 30rpx;
  3397. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  3398. }
  3399. .promise-title {
  3400. font-size: 34rpx;
  3401. font-weight: bold;
  3402. text-align: center;
  3403. margin-bottom: 20rpx;
  3404. color: #333;
  3405. }
  3406. .promise-text {
  3407. height: 600rpx;
  3408. margin-bottom: 20rpx;
  3409. /* padding: 20rpx; */
  3410. background-color: #f8f8f8;
  3411. border-radius: 8rpx;
  3412. font-size: 28rpx;
  3413. line-height: 1.6;
  3414. color: #333;
  3415. }
  3416. .promise-checkbox {
  3417. display: flex;
  3418. align-items: center;
  3419. margin-bottom: 30rpx;
  3420. padding: 0 10rpx;
  3421. }
  3422. .promise-checkbox text {
  3423. font-size: 28rpx;
  3424. margin-left: 10rpx;
  3425. color: #333;
  3426. }
  3427. .promise-buttons {
  3428. display: flex;
  3429. justify-content: center;
  3430. }
  3431. .promise-btn {
  3432. width: 200rpx;
  3433. height: 80rpx;
  3434. line-height: 80rpx;
  3435. text-align: center;
  3436. border-radius: 40rpx;
  3437. font-size: 28rpx;
  3438. }
  3439. .confirm-btn {
  3440. background-color: #0039b3;
  3441. color: #fff;
  3442. }
  3443. .confirm-btn[disabled] {
  3444. background-color: #cccccc;
  3445. color: #ffffff;
  3446. }
  3447. /* Loading indicator styles */
  3448. .loading-container {
  3449. position: fixed;
  3450. top: 0;
  3451. left: 0;
  3452. right: 0;
  3453. bottom: 0;
  3454. background-color: rgba(255, 255, 255, 0.8);
  3455. display: flex;
  3456. flex-direction: column;
  3457. justify-content: center;
  3458. align-items: center;
  3459. z-index: 1000;
  3460. }
  3461. .loading-spinner {
  3462. width: 60rpx;
  3463. height: 60rpx;
  3464. border: 6rpx solid #f3f3f3;
  3465. border-top: 6rpx solid #0039b3;
  3466. border-radius: 50%;
  3467. animation: spin 1s linear infinite;
  3468. margin-bottom: 20rpx;
  3469. }
  3470. .loading-text {
  3471. font-size: 28rpx;
  3472. color: #666;
  3473. }
  3474. @keyframes spin {
  3475. 0% { transform: rotate(0deg); }
  3476. 100% { transform: rotate(360deg); }
  3477. }
  3478. /* 添加开关样式 */
  3479. .form-item switch {
  3480. margin-top: 10rpx;
  3481. }
  3482. /* 修改必填项标签的样式 */
  3483. .label.required::before {
  3484. content: '*';
  3485. color: #ff4d4f;
  3486. margin-right: 4rpx;
  3487. position: absolute;
  3488. left: 0;
  3489. top: -4rpx;
  3490. }
  3491. /* 修改必填项标签的样式 */
  3492. /* .label.required::after {
  3493. content: '*';
  3494. color: #ff4d4f;
  3495. margin-left: 4rpx;
  3496. } */
  3497. </style>