jobIntention.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 MiSans-Medium" :disabled="deleteDisabled" @click="handleDelete">删 除</button>
  46. <button
  47. size="default"
  48. class="MiSans-Medium"
  49. :class="{'save-button': editId, 'commonBtnStyle': editId, 'send-button': !editId}"
  50. :disabled="disabled"
  51. @click="submit"
  52. >保 存</button>
  53. </view>
  54. </view>
  55. </template>
  56. <script setup>
  57. import { ref, unref } from 'vue'
  58. import { dictObj } from '@/utils/position.js'
  59. import { saveResumeJobInterested, getResumeJobInterested, deleteResumeJobInterested } from '@/api/resume.js'
  60. import { onLoad } from '@dcloudio/uni-app'
  61. import { cloneDeep } from 'lodash-es'
  62. import MSelect from '@/components/FilterList/select.vue'
  63. let formData = ref({ positionId: '', payFrom: 0, payTo: 0 })
  64. const form = ref()
  65. const editId = ref(null)
  66. // 获取求职意向
  67. async function getJobInterested (id) {
  68. const { data } = await getResumeJobInterested()
  69. if (!data || !data.length) {
  70. return
  71. }
  72. const obj = data.find(k => k.id === id)
  73. formData.value = cloneDeep(obj)
  74. formData.value.interestedAreaIdList = obj.interestedAreaIdList.map(e => +e)
  75. if (dictObj && dictObj?.areaTreeData) {
  76. const type = typeof dictObj.areaTreeData[0].id
  77. formData.value.workAreaId = type === 'string' ? obj.workAreaId.toString() : Number(obj.workAreaId)
  78. }
  79. }
  80. onLoad((options) => {
  81. if (options.id) {
  82. editId.value = options.id
  83. getJobInterested(options.id)
  84. }
  85. })
  86. // 提交
  87. const disabled = ref(false)
  88. const submit = async () => {
  89. const valid = await unref(form).validate()
  90. if (!valid) return
  91. // 后续做多选
  92. // const query = {...formData.value, industryIdList: formData.value.industryIdList, interestedAreaIdList: formData.value.interestedAreaIdList}
  93. disabled.value = true
  94. try {
  95. await saveResumeJobInterested(formData.value)
  96. uni.showToast({
  97. icon: 'success',
  98. title: '保存成功'
  99. })
  100. setTimeout(() => {
  101. editId.value = null
  102. uni.navigateBack({
  103. delta: 1
  104. })
  105. disabled.value = false
  106. }, 1000)
  107. } catch (err) {
  108. disabled.value = false
  109. uni.showToast({
  110. icon: 'none',
  111. title: err.msg
  112. })
  113. }
  114. }
  115. // 删除
  116. const deleteDisabled = ref(false)
  117. const handleDelete = async () => {
  118. deleteDisabled.value = true
  119. try {
  120. await deleteResumeJobInterested(editId.value)
  121. uni.showToast({
  122. icon: 'success',
  123. title: '删除成功'
  124. })
  125. setTimeout(() => {
  126. editId.value = null
  127. uni.navigateBack({
  128. delta: 1
  129. })
  130. deleteDisabled.value = false
  131. }, 1000)
  132. } catch (err) {
  133. deleteDisabled.value = false
  134. uni.showToast({
  135. icon: 'none',
  136. title: err.msg
  137. })
  138. }
  139. }
  140. const rules = {
  141. positionId:{
  142. rules: [{required: true, errorMessage: '请选择期望岗位' }]
  143. },
  144. industryIdList:{
  145. rules: [{required: true, errorMessage: '请选择期望行业' }]
  146. },
  147. payFrom:{
  148. rules: [{required: true, errorMessage: '请输入薪资最低要求' }]
  149. },
  150. payTo:{
  151. rules: [{required: true, errorMessage: '请输入薪资最高要求' }]
  152. },
  153. jobType:{
  154. rules: [{required: true, errorMessage: '请选择求职类型' }]
  155. },
  156. workAreaId:{
  157. rules: [{required: true, errorMessage: '请选择工作城市' }]
  158. },
  159. }
  160. const payToMin = ref(1)
  161. const payChange = (val) => {
  162. payToMin.value = val
  163. if (val > formData.value.payTo) formData.value.payTo = val
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. :deep(.uni-forms-item__content) {
  168. max-width: 100%;
  169. overflow: hidden;
  170. }
  171. </style>