jobIntention.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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-filter
  10. label="请选择期望行业"
  11. :items="dictObj?.industryTreeData || []"
  12. item-label="nameCn"
  13. item-value="id"
  14. multiple
  15. :value="industryIdObj.id"
  16. @change="industryChange"
  17. @init="industryInit"
  18. >
  19. <view class="content">
  20. <view class="content-cover"></view>
  21. <uni-easyinput v-model="industryIdObj.label" placeholder="请选择期望行业" :clearable="false"/>
  22. </view>
  23. </m-filter>
  24. <!-- <uni-data-picker popup-title="请选择期望行业" v-model="formData.industryIdList" :localdata="dictObj?.industryTreeData || []" :clear-icon="false" :map="{ text: 'nameCn', value: 'id'}"></uni-data-picker> -->
  25. </uni-forms-item>
  26. <uni-forms-item label="最低薪资" name="payFrom" required label-width="90px">
  27. <uni-number-box v-model="formData.payFrom" :min="1" :max="999999999" :step="1000" :width="150" @change="payChange"></uni-number-box>
  28. </uni-forms-item>
  29. <uni-forms-item label="最高薪资" name="payTo" required label-width="90px">
  30. <uni-number-box v-model="formData.payTo" :min="payToMin" :max="999999999" :step="1000" :width="150"></uni-number-box>
  31. </uni-forms-item>
  32. <uni-forms-item label="求职类型" name="jobType" required label-width="90px">
  33. <uni-data-picker popup-title="请选择求职类型" v-model="formData.jobType" :localdata="dictObj?.jobType || []" :clear-icon="false" :map="{ text: 'label', value: 'value'}"></uni-data-picker>
  34. </uni-forms-item>
  35. <uni-forms-item label="工作城市" name="workAreaId" required label-width="90px">
  36. <uni-data-picker popup-title="请选择工作城市" v-model="formData.workAreaId" :localdata="dictObj?.areaTreeData || []" :clear-icon="false" :map="{ text: 'name', value: 'id'}"></uni-data-picker>
  37. </uni-forms-item>
  38. <uni-forms-item label="其它感兴趣的城市" name="interestedAreaIdList" label-width="90px">
  39. <!-- <uni-data-picker popup-title="其它感兴趣的城市" v-model="formData.interestedAreaIdList" :localdata="dictObj?.areaTreeData || []" :clear-icon="false" :map="{ text: 'name', value: 'id'}"></uni-data-picker> -->
  40. <m-filter
  41. label="请选择其它感兴趣的城市"
  42. :items="dictObj?.areaTreeData || []"
  43. item-label="name"
  44. item-value="id"
  45. multiple
  46. :value="interestedAreaIdObj.id"
  47. @change="interestedAreaChange"
  48. @init="interestedAreaInit"
  49. >
  50. <view class="content">
  51. <view class="content-cover"></view>
  52. <uni-easyinput v-model="interestedAreaIdObj.label" placeholder="请选择其它感兴趣的城市" :clearable="false"/>
  53. </view>
  54. </m-filter>
  55. </uni-forms-item>
  56. </uni-forms>
  57. <view class="f-horizon-center">
  58. <button v-if="editId" size="default" class="delete-button commonBtnStyle" @click="handleDelete">删 除</button>
  59. <button size="default" :class="{'save-button': editId, 'commonBtnStyle': editId, 'send-button': !editId}" @click="submit">保 存</button>
  60. </view>
  61. </view>
  62. </template>
  63. <script setup>
  64. import { ref, unref } from 'vue'
  65. import { dictObj } from '@/utils/position.js'
  66. import { saveResumeJobInterested, getResumeJobInterested, deleteResumeJobInterested } from '@/api/resume.js'
  67. import { onLoad } from '@dcloudio/uni-app'
  68. import { cloneDeep } from 'lodash-es'
  69. import MFilter from '@/components/FilterList/mFilter'
  70. let formData = ref({ positionId: '', payFrom: 0, payTo: 0 })
  71. const form = ref()
  72. const editId = ref(null)
  73. // 预览 回显 期望行业
  74. const industryIdObj = ref({
  75. id: null,
  76. label: null
  77. })
  78. // 预览 回显 感兴趣城市
  79. const interestedAreaIdObj = ref({
  80. id: null,
  81. label: null
  82. })
  83. // 获取求职意向
  84. async function getJobInterested (id) {
  85. const { data } = await getResumeJobInterested()
  86. if (!data || !data.length) {
  87. return
  88. }
  89. const obj = data.find(k => k.id === id)
  90. formData.value = cloneDeep(obj)
  91. // formData.value.industryIdList = obj.industryIdList?.length ? obj.industryIdList[0] : ''
  92. industryIdObj.value.id = obj.industryIdList
  93. // formData.value.interestedAreaIdList = obj.interestedAreaIdList
  94. interestedAreaIdObj.value.id = obj.interestedAreaIdList.map(e => +e)
  95. console.log(interestedAreaIdObj.value)
  96. if (dictObj && dictObj?.areaTreeData) {
  97. const type = typeof dictObj.areaTreeData[0].id
  98. formData.value.workAreaId = type === 'string' ? obj.workAreaId.toString() : Number(obj.workAreaId)
  99. }
  100. }
  101. onLoad((options) => {
  102. if (options.id) {
  103. editId.value = options.id
  104. getJobInterested(options.id)
  105. }
  106. })
  107. // 提交
  108. const submit = async () => {
  109. const valid = await unref(form).validate()
  110. if (!valid) return
  111. // 后续做多选
  112. // const query = {...formData.value, industryIdList: formData.value.industryIdList, interestedAreaIdList: formData.value.interestedAreaIdList}
  113. try {
  114. await saveResumeJobInterested(formData.value)
  115. uni.showToast({
  116. icon: 'success',
  117. title: '保存成功'
  118. })
  119. setTimeout(() => {
  120. editId.value = null
  121. uni.navigateBack({
  122. delta: 1
  123. })
  124. }, 1000)
  125. } catch (err) {
  126. uni.showToast({
  127. icon: 'none',
  128. title: err.msg
  129. })
  130. }
  131. }
  132. // 删除
  133. const handleDelete = async () => {
  134. try {
  135. await deleteResumeJobInterested(editId.value)
  136. uni.showToast({
  137. icon: 'success',
  138. title: '删除成功'
  139. })
  140. setTimeout(() => {
  141. editId.value = null
  142. uni.navigateBack({
  143. delta: 1
  144. })
  145. }, 1000)
  146. } catch (err) {
  147. uni.showToast({
  148. icon: 'none',
  149. title: err.msg
  150. })
  151. }
  152. }
  153. const rules = {
  154. positionId:{
  155. rules: [{required: true, errorMessage: '请选择期望岗位' }]
  156. },
  157. industryIdList:{
  158. rules: [{required: true, errorMessage: '请选择期望行业' }]
  159. },
  160. payFrom:{
  161. rules: [{required: true, errorMessage: '请输入薪资最低要求' }]
  162. },
  163. payTo:{
  164. rules: [{required: true, errorMessage: '请输入薪资最高要求' }]
  165. },
  166. jobType:{
  167. rules: [{required: true, errorMessage: '请选择求职类型' }]
  168. },
  169. workAreaId:{
  170. rules: [{required: true, errorMessage: '请选择工作城市' }]
  171. },
  172. }
  173. const payToMin = ref(1)
  174. const payChange = (val) => {
  175. payToMin.value = val
  176. if (val > formData.value.payTo) formData.value.payTo = val
  177. }
  178. // 选中
  179. const industryChange = (value, label, item) => {
  180. if (!value.length) {
  181. industryIdObj.value.label = null
  182. formData.value.industryIdList = null
  183. return
  184. }
  185. industryIdObj.value.label = item.data.filter(e => value.includes(e.id)).map(e => e.nameCn)
  186. formData.value.industryIdList = value
  187. }
  188. // 回显
  189. const industryInit = (label) => {
  190. industryIdObj.value.label = label
  191. }
  192. // 选中
  193. const interestedAreaChange = (value, label, item) => {
  194. if (!value.length) {
  195. interestedAreaIdObj.value.label = null
  196. formData.value.interestedAreaIdList = null
  197. return
  198. }
  199. interestedAreaIdObj.value.label = item.data.filter(e => value.includes(e.id)).map(e => e.name)
  200. formData.value.interestedAreaIdList = value
  201. }
  202. // 回显
  203. const interestedAreaInit = (label) => {
  204. interestedAreaIdObj.value.label = label
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. .content {
  209. position: relative;
  210. &-cover {
  211. position: absolute;
  212. width: 100%;
  213. height: 100%;
  214. left: 0;
  215. top: 0;
  216. z-index: 3;
  217. }
  218. }
  219. </style>