jobIntention.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!-- -->
  2. <template>
  3. <view class="ss-m-x-30 ss-m-y-30">
  4. <uni-forms ref="form" :modelValue="formData" :rules="rules" validateTrigger="bind">
  5. <uni-forms-item label="期望岗位" name="positionId" required label-width="90px">
  6. <uni-data-picker popup-title="请选择期望岗位" v-model="formData.positionId" :localdata="dictObj?.positionTreeData || []" :clear-icon="false" :map="{ text: 'nameCn', value: 'id'}"></uni-data-picker>
  7. </uni-forms-item>
  8. <uni-forms-item label="期望行业" name="industryIdList" required label-width="90px">
  9. <m-select
  10. label="请选择期望行业"
  11. :items="dictObj?.industryTreeData || []"
  12. item-label="nameCn"
  13. item-value="id"
  14. multiple
  15. v-model="formData.industryIdList"
  16. ></m-select>
  17. <!-- <uni-data-picker popup-title="请选择期望行业" v-model="formData.industryIdList" :localdata="dictObj?.industryTreeData || []" :clear-icon="false" :map="{ text: 'nameCn', value: 'id'}"></uni-data-picker> -->
  18. </uni-forms-item>
  19. <uni-forms-item label="最低薪资" name="payFrom" required label-width="90px">
  20. <uni-number-box v-model="formData.payFrom" :min="1" :max="999999999" :step="1000" :width="150" @change="payChange"></uni-number-box>
  21. </uni-forms-item>
  22. <uni-forms-item label="最高薪资" name="payTo" required label-width="90px">
  23. <uni-number-box v-model="formData.payTo" :min="payToMin" :max="999999999" :step="1000" :width="150"></uni-number-box>
  24. </uni-forms-item>
  25. <uni-forms-item label="求职类型" name="jobType" required label-width="90px">
  26. <uni-data-picker popup-title="请选择求职类型" v-model="formData.jobType" :localdata="dictObj?.jobType || []" :clear-icon="false" :map="{ text: 'label', value: 'value'}"></uni-data-picker>
  27. </uni-forms-item>
  28. <uni-forms-item label="工作城市" name="workAreaId" required label-width="90px">
  29. <uni-data-picker popup-title="请选择工作城市" v-model="formData.workAreaId" :localdata="dictObj?.areaTreeData || []" :clear-icon="false" :map="{ text: 'name', value: 'id'}"></uni-data-picker>
  30. </uni-forms-item>
  31. <uni-forms-item label="其它感兴趣的城市" name="interestedAreaIdList" label-width="90px">
  32. <!-- <uni-data-picker popup-title="其它感兴趣的城市" v-model="formData.interestedAreaIdList" :localdata="dictObj?.areaTreeData || []" :clear-icon="false" :map="{ text: 'name', value: 'id'}"></uni-data-picker> -->
  33. <m-select
  34. label="请选择其它感兴趣的城市"
  35. :items="dictObj?.areaTreeData || []"
  36. item-label="name"
  37. item-value="id"
  38. multiple
  39. v-model="formData.interestedAreaIdList"
  40. >
  41. </m-select>
  42. </uni-forms-item>
  43. </uni-forms>
  44. <view class="f-horizon-center">
  45. <button v-if="editId" size="default" class="delete-button commonBtnStyle" @click="handleDelete">删 除</button>
  46. <button size="default" :class="{'save-button': editId, 'commonBtnStyle': editId, 'send-button': !editId}" @click="submit">保 存</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script setup>
  51. import { ref, unref } from 'vue'
  52. import { dictObj } from '@/utils/position.js'
  53. import { saveResumeJobInterested, getResumeJobInterested, deleteResumeJobInterested } from '@/api/resume.js'
  54. import { onLoad } from '@dcloudio/uni-app'
  55. import { cloneDeep } from 'lodash-es'
  56. import MSelect from '@/components/FilterList/select.vue'
  57. let formData = ref({ positionId: '', payFrom: 0, payTo: 0 })
  58. const form = ref()
  59. const editId = ref(null)
  60. // 获取求职意向
  61. async function getJobInterested (id) {
  62. const { data } = await getResumeJobInterested()
  63. if (!data || !data.length) {
  64. return
  65. }
  66. const obj = data.find(k => k.id === id)
  67. formData.value = cloneDeep(obj)
  68. formData.value.interestedAreaIdList = obj.interestedAreaIdList.map(e => +e)
  69. if (dictObj && dictObj?.areaTreeData) {
  70. const type = typeof dictObj.areaTreeData[0].id
  71. formData.value.workAreaId = type === 'string' ? obj.workAreaId.toString() : Number(obj.workAreaId)
  72. }
  73. }
  74. onLoad((options) => {
  75. if (options.id) {
  76. editId.value = options.id
  77. getJobInterested(options.id)
  78. }
  79. })
  80. // 提交
  81. const submit = async () => {
  82. const valid = await unref(form).validate()
  83. if (!valid) return
  84. // 后续做多选
  85. // const query = {...formData.value, industryIdList: formData.value.industryIdList, interestedAreaIdList: formData.value.interestedAreaIdList}
  86. try {
  87. await saveResumeJobInterested(formData.value)
  88. uni.showToast({
  89. icon: 'success',
  90. title: '保存成功'
  91. })
  92. setTimeout(() => {
  93. editId.value = null
  94. uni.navigateBack({
  95. delta: 1
  96. })
  97. }, 1000)
  98. } catch (err) {
  99. uni.showToast({
  100. icon: 'none',
  101. title: err.msg
  102. })
  103. }
  104. }
  105. // 删除
  106. const handleDelete = async () => {
  107. try {
  108. await deleteResumeJobInterested(editId.value)
  109. uni.showToast({
  110. icon: 'success',
  111. title: '删除成功'
  112. })
  113. setTimeout(() => {
  114. editId.value = null
  115. uni.navigateBack({
  116. delta: 1
  117. })
  118. }, 1000)
  119. } catch (err) {
  120. uni.showToast({
  121. icon: 'none',
  122. title: err.msg
  123. })
  124. }
  125. }
  126. const rules = {
  127. positionId:{
  128. rules: [{required: true, errorMessage: '请选择期望岗位' }]
  129. },
  130. industryIdList:{
  131. rules: [{required: true, errorMessage: '请选择期望行业' }]
  132. },
  133. payFrom:{
  134. rules: [{required: true, errorMessage: '请输入薪资最低要求' }]
  135. },
  136. payTo:{
  137. rules: [{required: true, errorMessage: '请输入薪资最高要求' }]
  138. },
  139. jobType:{
  140. rules: [{required: true, errorMessage: '请选择求职类型' }]
  141. },
  142. workAreaId:{
  143. rules: [{required: true, errorMessage: '请选择工作城市' }]
  144. },
  145. }
  146. const payToMin = ref(1)
  147. const payChange = (val) => {
  148. payToMin.value = val
  149. if (val > formData.value.payTo) formData.value.payTo = val
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .content {
  154. position: relative;
  155. &-cover {
  156. position: absolute;
  157. width: 100%;
  158. height: 100%;
  159. left: 0;
  160. top: 0;
  161. z-index: 3;
  162. }
  163. }
  164. :deep(.uni-forms-item__content) {
  165. max-width: 100%;
  166. overflow: hidden;
  167. }
  168. </style>