123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <div>
- <CtForm ref="formPageRef" :items="items" style="width: 650px;">
- <template #bizId="{ item }">
- <div>
- <v-checkbox-btn
- v-model="jobFairCheckbox"
- color="primary"
- label="设置为招聘会职位"
- class="ml-2"
- :disabled="false"
- :style="`line-height: ${item.dense === 'default' ? 56 : item.dense === 'comfortable' ? 48 : 40 }px;`"
- style="width: 174px;"
- hide-details
- @update:modelValue="v => jobFairCheckboxChange(v, item)"
- ></v-checkbox-btn>
- </div>
- </template>
- <template #positionId="{ item }">
- <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs">
- <template v-slot:activator="{ props }">
- <textUI
- :modelValue="item.value"
- :item="item"
- v-bind="props"
- style="position: relative;"
- ></textUI>
- </template>
- <jobTypeCard class="jobTypeCardBox" :select="[query.positionId].filter(Boolean)" :isSingle="true" @handleJobClick="handleJobClickItem"></jobTypeCard>
- </v-menu>
- <v-btn v-if="showTemplateBtn" class="ml-3 half-button" color="primary" style="margin-top: 2px;" @click="useJobTemplate(item)">职位模板</v-btn>
- </template>
- <template #expireTime="{ item }">
- <div>
- <v-checkbox-btn
- v-model="soFar"
- color="primary"
- label="长期有效"
- class="ml-2"
- :disabled="false"
- :style="`line-height: ${item.dense === 'default' ? 56 : item.dense === 'comfortable' ? 48 : 40 }px;`"
- style="width: 110px;"
- hide-details
- @update:modelValue="v => handleSoFarChange(v, item)"
- ></v-checkbox-btn>
- </div>
- </template>
- </CtForm>
- </div>
- </template>
- <script setup>
- defineOptions({ name: 'position-add-baseInfo'})
- import CtForm from '@/components/CtForm'
- import { reactive, ref, watch } from 'vue'
- import textUI from '@/components/FormUI/TextInput'
- import jobTypeCard from '@/components/jobTypeCard'
- import { getRecruitPositionDetails } from '@/api/recruit/enterprise/position'
- import Confirm from '@/plugins/confirm'
- import Snackbar from '@/plugins/snackbar'
- import { useI18n } from '@/hooks/web/useI18n';
- import { getJobFairList } from '@/api/recruit/enterprise/jobFair'
- const { t } = useI18n()
- const props = defineProps({
- itemData: Object
- })
- const getValue = (key) => {
- return items.value.options.find(e => e.key === key)
- }
- const showTemplateBtn = ref(true)
- const formPageRef = ref()
- let query = reactive({})
- const items = ref({
- options: [
- {
- slotName: 'bizId',
- type: 'autocomplete',
- key: 'bizId',
- value: null,
- label: '招聘会',
- itemText: 'title',
- itemValue: 'id',
- disabled: true,
- items: [],
- },
- {
- slotName: 'positionId',
- key: 'positionId',
- value: '',
- flexStyle: 'mt-5',
- labelKey: 'positionName',
- label: '职位类型 *',
- noParam: true,
- readonly: true,
- rules: [v => !!v || '请选择职位类型']
- },
- {
- type: 'text',
- key: 'name',
- value: '',
- label: '职位名称 *',
- rules: [v => !!v || '请填写职位名称']
- },
- {
- type: 'datePicker',
- key: 'expireTime',
- value: null,
- format: 'YYYY-MM-DD',
- label: '到期时间 *',
- disabledDate: true,
- dayAfter: true,
- labelWidth: 120,
- slotName: 'expireTime',
- },
- {
- type: 'wangEditor',
- key: 'content',
- value: '',
- label: '岗位职责 *',
- maxLength: 5000,
- rules: '请填写岗位职责'
- },
- {
- type: 'wangEditor',
- key: 'requirement',
- value: '',
- label: '岗位要求 *',
- maxLength: 5000,
- rules: '请填写岗位要求'
- }
- ]
- })
- // 编辑回显
- watch(
- () => props.itemData,
- (val) => {
- if (!Object.keys(val).length) return
- items.value.options.forEach(e => {
- if (e.labelKey) {
- query[e.key] = val[e.key]
- e.value = val[e.labelKey]
- return
- }
- if (e.noParam) return
- if (e.key === 'expireTime' && !val[e.key]) return handleSoFarChange(true, e)
- if (e.key === 'bizId' && val.source === '2') jobFairCheckboxChange(true, e) // 招聘会回显
- if (e.key === 'bizId' && val.source === '0') val[e.key] = null // 非招聘会职位
- e.value = val[e.key]
- })
- },
- { immediate: true },
- { deep: true }
- )
- // 职位类型
- const handleJobClickItem = (list, name) => {
- const positionId = getValue('positionId')
- if (!list.length) {
- delete query.positionId
- positionId.value = ''
- return
- }
- showTemplateBtn.value = true
- query.positionId = list[0]
- positionId.value = name
- }
- const useJobTemplate = async () => {
- if (!query.positionId) return Snackbar.warning('请先选择职位类型')
- // 获取职位模板内容-赋值
- const res = await getRecruitPositionDetails(query.positionId)
- if (!res || !res.content || !res.requirement) {
- Snackbar.warning('此职位类型没有可使用的模板!')
- showTemplateBtn.value = false
- return
- }
- const content = items.value.options.find(e => e.key === 'content')
- const requirement = items.value.options.find(e => e.key === 'requirement')
- if ((content && content.value) || (requirement && requirement.value)) {
- // 弹窗提示
- Confirm(t('common.confirmTitle'), '您确定要放弃目前岗位描述的内容吗?').then(() => {
- content.value = res.content
- requirement.value = res.requirement
- Snackbar.success('模板填充完成!')
- })
- } else {
- // 无内容点击默认填充
- if (content) content.value = res.content
- if (requirement) requirement.value = res.requirement
- Snackbar.success('模板填充完成!')
- }
- }
- const soFar = ref(false)
- // 长期有效
- const handleSoFarChange = (bool, item) => {
- soFar.value = bool
- item.value = null
- item.disabled = bool ? true : false
- item.label = bool ? '到期时间' : '到期时间 *'
- }
- // 设置为招聘会职位
- const jobFairCheckbox = ref(false)
- const jobFairCheckboxChange = (bool, item) => {
- jobFairCheckbox.value = bool
- item.value = null
- item.disabled = bool ? false : true
- item.label = bool ? '招聘会 *' : '招聘会'
- }
- const getJobFairData = async () => {
- const data = await getJobFairList()
- const bizId = items.value.options.find(e => e.key === 'bizId')
- if (!bizId) return
- bizId.items = data
- }
- getJobFairData()
- const getQuery = async () => {
- const { valid } = await formPageRef.value.formRef.validate()
- if (!valid) return
- const obj = {
- hirePrice: 0,
- soFar: soFar.value,
- hire: false
- }
- items.value.options.forEach(e => {
- if (e.noParam || e.value === null) return
- else obj[e.key] = e.value
- })
-
- if (jobFairCheckbox.value && !obj.bizId) {
- Snackbar.warning('请选择招聘会')
- return 'failed'
- }
- if (!obj.content) {
- Snackbar.warning('请填写岗位职责')
- return 'failed'
- }
- if (!obj.requirement) {
- Snackbar.warning('请填写岗位要求')
- return 'failed'
- }
- if (!obj.expireTime && !soFar.value) {
- Snackbar.warning('请填写到期时间')
- return 'failed'
- }
-
- obj.source = jobFairCheckbox.value ? '2' : '0' // 职位来源(0职位管理|1众聘职位|2招聘会)
- if (obj.source === '0') obj.bizId = null
- Object.assign(query, obj)
- // console.log('obj:', obj)
- console.log('query:', query)
- return query
- }
- defineExpose({
- formPageRef,
- getQuery
- })
- </script>
- <style scoped lang="scss">
- .jobTypeCardBox {
- position: absolute;
- top: -22px;
- left: 0;
- }
- .calculation {
- display: block;
- width: 120px;
- }
- </style>
|