baseInfo.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="mt-10">
  3. <CtForm ref="formPageRef" :items="items" style="width: 650px;">
  4. <template #numericalValue>
  5. <div class="font-size-14 color-error my-1">
  6. <div class="d-flex align-center font-size-13">
  7. <div style="color: var(--v-error-base); cursor: pointer; text-decoration: underline;" @click="handleViewRule">
  8. <v-icon size="20" color="error">mdi-help-circle-outline</v-icon>
  9. 众聘岗位规则说明。
  10. </div>
  11. <div class=" ml-5" style="color: var(--v-error-base);">
  12. 众聘岗位分配比例:推荐人占比{{ ratio.recommendRate }}%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 平台占比{{ ratio.headhuntRate }}%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 投递人占比{{ ratio.cvRate }}%
  13. </div>
  14. </div>
  15. <div class="d-flex">
  16. 按众聘岗位分配比例计算后的赏金:
  17. <span class="calculation ml-3">推荐人{{ calculation('hirePrice', 1, true) }}元</span>
  18. <span class="calculation">平台{{ calculation('hirePrice', 0, true) }}元</span>
  19. <span class="calculation">投递人{{ calculation('hirePrice', 2, true) }}元</span>
  20. </div>
  21. </div>
  22. </template>
  23. <template #positionId="{ item }">
  24. <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs">
  25. <template v-slot:activator="{ props }">
  26. <textUI
  27. :modelValue="item.value"
  28. :item="item"
  29. v-bind="props"
  30. style="position: relative;"
  31. ></textUI>
  32. </template>
  33. <jobTypeCard class="jobTypeCardBox" :select="[query.positionId].filter(Boolean)" :isSingle="true" @handleJobClick="handleJobClickItem"></jobTypeCard>
  34. </v-menu>
  35. <v-btn v-if="showTemplateBtn" class="ml-3 half-button" color="primary" style="margin-top: 2px;" @click="useJobTemplate(item)">职位模板</v-btn>
  36. </template>
  37. </CtForm>
  38. <CtDialog :visible="show" :widthType="1" titleClass="text-h6" title="众聘岗位规则说明" :footer="false" @close="show = false">
  39. <RulePage />
  40. </CtDialog>
  41. </div>
  42. </template>
  43. <script setup>
  44. defineOptions({ name: 'position-add-baseInfo'})
  45. import CtForm from '@/components/CtForm'
  46. import { reactive, ref, watch } from 'vue'
  47. import textUI from '@/components/FormUI/TextInput'
  48. import jobTypeCard from '@/components/jobTypeCard'
  49. import RulePage from './rule.vue'
  50. import { commissionCalculation } from '@/utils/position'
  51. import { getPublicRatio, getRecruitPositionDetails } from '@/api/recruit/enterprise/position'
  52. const props = defineProps({
  53. itemData: Object
  54. })
  55. const showTemplateBtn = ref(true)
  56. const show = ref(false)
  57. const ratio = ref({})
  58. // 按分配比例计算金额积分
  59. const calculation = (key, type) => {
  60. const value = items.value.options.find(e => e.key === key).value
  61. return commissionCalculation(value, type)
  62. }
  63. const getValue = (key) => {
  64. return items.value.options.find(e => e.key === key)
  65. }
  66. const formPageRef = ref()
  67. let query = reactive({})
  68. const items = ref({
  69. options: [
  70. {
  71. type: 'number',
  72. key: 'hirePrice',
  73. value: null,
  74. label: '请填写点数 * (1赏金=10点数,点数填入不得少于10且为10的倍数)',
  75. suffix: '点',
  76. hideDetails: true,
  77. change: val => hirePriceChange(val, 'hirePrice')
  78. },
  79. {
  80. slotName: 'numericalValue',
  81. noParam: true,
  82. },
  83. {
  84. type: 'text',
  85. key: 'name',
  86. value: '',
  87. label: '职位名称 *',
  88. rules: [v => !!v || '请填写职位名称']
  89. },
  90. {
  91. type: 'datePicker',
  92. key: 'expireTime',
  93. value: null,
  94. format: 'YYYY-MM-DD',
  95. labelWidth: 120,
  96. label: '到期时间 *'
  97. },
  98. {
  99. slotName: 'positionId',
  100. key: 'positionId',
  101. value: '',
  102. labelKey: 'positionName',
  103. label: '职位类型 *',
  104. noParam: true,
  105. flexStyle: 'mt-5',
  106. readonly: true,
  107. rules: [v => !!v || '请选择职位类型']
  108. },
  109. {
  110. type: 'wangEditor',
  111. key: 'content',
  112. value: '',
  113. label: '岗位职责 *',
  114. maxLength: 5000,
  115. rules: '请填写岗位职责'
  116. },
  117. {
  118. type: 'wangEditor',
  119. key: 'requirement',
  120. value: '',
  121. label: '岗位要求 *',
  122. maxLength: 5000,
  123. rules: '请填写岗位要求'
  124. }
  125. ]
  126. })
  127. // 获取众聘分配比例
  128. const getRatio = async () => {
  129. const data = await getPublicRatio()
  130. ratio.value = data
  131. }
  132. getRatio()
  133. // 编辑回显
  134. watch(
  135. () => props.itemData,
  136. (val) => {
  137. if (!Object.keys(val).length) return
  138. items.value.options.forEach(e => {
  139. if (e.labelKey) {
  140. query[e.key] = val[e.key]
  141. e.value = val[e.labelKey]
  142. return
  143. }
  144. if (e.noParam) return
  145. e.value = val[e.key]
  146. e.change && e.change(e.value)
  147. })
  148. },
  149. { immediate: true },
  150. { deep: true }
  151. )
  152. // 职位类型
  153. const handleJobClickItem = (list, name) => {
  154. const positionId = getValue('positionId')
  155. if (!list.length) {
  156. delete query.positionId
  157. positionId.value = ''
  158. return
  159. }
  160. showTemplateBtn.value = true
  161. query.positionId = list[0]
  162. positionId.value = name
  163. }
  164. // 职位模板
  165. import Confirm from '@/plugins/confirm'
  166. import Snackbar from '@/plugins/snackbar'
  167. import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
  168. const useJobTemplate = async () => {
  169. if (!query.positionId) return Snackbar.warning('请先选择职位类型')
  170. // 获取职位模板内容-赋值
  171. const res = await getRecruitPositionDetails(query.positionId)
  172. if (!res || !res.content || !res.requirement) {
  173. Snackbar.warning('此职位类型没有可使用的模板!')
  174. showTemplateBtn.value = false
  175. return
  176. }
  177. const content = items.value.options.find(e => e.key === 'content')
  178. const requirement = items.value.options.find(e => e.key === 'requirement')
  179. if ((content && content.value) || (requirement && requirement.value)) {
  180. // 弹窗提示
  181. Confirm(t('common.confirmTitle'), '您确定要放弃目前岗位描述的内容吗?').then(() => {
  182. content.value = res.content
  183. requirement.value = res.requirement
  184. Snackbar.success('模板填充完成!')
  185. })
  186. } else {
  187. // 无内容点击默认填充
  188. if (content) content.value = res.content
  189. if (requirement) requirement.value = res.requirement
  190. Snackbar.success('模板填充完成!')
  191. }
  192. }
  193. // 众聘规则查看
  194. const handleViewRule = () => {
  195. show.value = true
  196. }
  197. // 众聘规则查看
  198. const hirePriceChange = (value, key) => {
  199. let calcCost = value-0
  200. if (calcCost < 10 ) calcCost = 10
  201. else {
  202. calcCost = parseInt(calcCost/10)*10
  203. }
  204. const obj = items.value.options.find(k => k.key === key)
  205. if (obj) {
  206. obj.value = calcCost
  207. }
  208. }
  209. const getQuery = async () => {
  210. const { valid } = await formPageRef.value.formRef.validate()
  211. if (!valid) return
  212. const obj = {
  213. hire: true
  214. }
  215. items.value.options.forEach(e => {
  216. if (e.noParam) return
  217. else obj[e.key] = e.value
  218. })
  219. if (!obj.content) {
  220. Snackbar.warning('请填写岗位职责')
  221. return 'failed'
  222. }
  223. if (!obj.requirement) {
  224. Snackbar.warning('请填写岗位要求')
  225. return 'failed'
  226. }
  227. query = Object.assign(query, obj)
  228. return query
  229. }
  230. defineExpose({
  231. formPageRef,
  232. getQuery
  233. })
  234. </script>
  235. <style scoped lang="scss">
  236. .jobTypeCardBox {
  237. position: absolute;
  238. top: -22px;
  239. left: 0;
  240. }
  241. .calculation {
  242. display: block;
  243. width: 120px;
  244. }
  245. </style>