招聘岗位、基地增删改查

This commit is contained in:
Leo_Ding 2025-06-18 15:14:56 +08:00
parent 07aff7d469
commit f6eec94b31
12 changed files with 263 additions and 891 deletions

View File

@ -0,0 +1,19 @@
/**
* 海邻招聘岗位接口
*/
import request from '@/utils/request'
// 获取招聘岗位列表
export const getDataList = (params) => request.basic.get('/api/v1/jobs', params)
// 获取单条数据
export const getItem = (id) => request.basic.get(`/api/v1/jobs/${id}`)
// 添加岗位
export const createItem = (params) => request.basic.post('/api/v1/jobs', params)
// 更新岗位
export const updateItem = (id, params) => request.basic.put(`/api/v1/jobs/${id}`, params)
// 删除岗位
export const delItem = (id) => request.basic.delete(`/api/v1/jobs/${id}`)
// 获取招聘岗位基地列表
export const getAreasList = (params) => request.basic.get('/api/v1/jobs/job_areas', params)
// 添加基地
export const createAreaItem = (params) => request.basic.post('/api/v1/jobs/job_areas', params)

View File

@ -4,3 +4,4 @@ export { default as useMenu } from './useMenu'
export { default as useModal } from './useModal' export { default as useModal } from './useModal'
export { default as useMultiTab } from './useMultiTab' export { default as useMultiTab } from './useMultiTab'
export { default as usePagination } from './usePagination' export { default as usePagination } from './usePagination'
export { default as useSpining } from './useSpining'

19
src/hooks/useSpining.js Normal file
View File

@ -0,0 +1,19 @@
import { ref } from 'vue'
export default () => {
const spining = ref(false) // 直接使用基本类型ref
const showSpining = () => {
spining.value = true
}
const hideSpining = () => {
spining.value = false
}
return {
spining, // 直接暴露ref
showSpining,
hideSpining
}
}

6
src/main.css Normal file
View File

@ -0,0 +1,6 @@
.text-ellipsis{
width: 100%;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}

View File

@ -2,6 +2,7 @@ import { createApp } from 'vue'
import imgErr from '@/assets/imgerror.png' import imgErr from '@/assets/imgerror.png'
import App from '@/App.vue' import App from '@/App.vue'
import { useCore } from '@/core' import { useCore } from '@/core'
import './main.css'
const app = createApp(App) const app = createApp(App)
app.config.globalProperties.$imageErr={imgErr} app.config.globalProperties.$imageErr={imgErr}

View File

@ -1,169 +0,0 @@
<template>
<a-card
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
:style="{
position: 'sticky',
top: appStore.mainOffsetTop,
height: appStore.mainHeight,
}">
<template #title>
<a-input-search placeholder="搜索部门"></a-input-search>
</template>
<x-scrollbar class="pa-8-2">
<a-spin :spinning="loading">
<a-tree
block-node
:selected-keys="selectedKeys"
:tree-data="listData"
:field-names="{ key: 'id', children: 'children' }"
@select="onSelect">
<template #title="{ title }">
<span class="ant-tree-title__name">{{ title }}</span>
<span class="ant-tree-title__actions">
<a-dropdown
:trigger="['click']"
@click.stop>
<x-action-button>
<more-outlined></more-outlined>
</x-action-button>
<template #overlay>
<a-menu>
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
添加子部门
</a-menu-item>
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
编辑
</a-menu-item>
<a-menu-item @click="handleDelete">删除</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</span>
</template>
</a-tree>
<empty
v-if="!listData.length"
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
</a-spin>
</x-scrollbar>
<template #actions>
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
<plus-outlined></plus-outlined>
新建部门
</span>
</template>
</a-card>
<edit-department-dialog
ref="editDepartmentDialogRef"
@ok="onOk"></edit-department-dialog>
</template>
<script setup>
import { useAppStore } from '@/store'
import { ref, watch } from 'vue'
import { usePagination } from '@/hooks'
import apis from '@/apis'
import { Empty, Modal, message } from 'ant-design-vue'
import { config } from '@/config'
import { head, get, find } from 'lodash-es'
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
import EditDepartmentDialog from './EditDepartmentDialog.vue'
const props = defineProps({
value: {
type: String,
default: '',
},
})
const emit = defineEmits(['change', 'update:value'])
const appStore = useAppStore()
const { listData, loading, showLoading, hideLoading } = usePagination()
const editDepartmentDialogRef = ref()
const selectedKeys = ref([props.value])
watch(
() => props.value,
(val) => {
if (val === selectedKeys.value?.[0]) return
selectedKeys.value = [val]
}
)
getList()
/**
* 获取列表
* @returns {Promise<void>}
*/
async function getList() {
try {
showLoading()
const { code, data } = await apis.common.getPageList().catch(() => {
throw new Error()
})
hideLoading()
if (config('http.code.success') === code) {
const { records } = data
listData.value = records
if (listData.value.length) {
selectedKeys.value = [get(head(listData.value), 'id')]
trigger()
}
}
} catch (error) {
hideLoading()
}
}
/**
* 删除
*/
function handleDelete({ id }) {
Modal.confirm({
title: '删除提示',
content: '确认删除?',
okText: '确认',
onOk: () => {
return new Promise((resolve, reject) => {
;(async () => {
try {
const { code } = await apis.common.del(id).catch(() => {
throw new Error()
})
if (config('http.code.success') === code) {
resolve()
message.success('删除成功')
await getList()
}
} catch (error) {
reject()
}
})()
})
},
})
}
function onSelect(keys) {
if (!keys.length) return
selectedKeys.value = keys
trigger()
}
async function onOk() {
await getList()
}
function trigger() {
const value = head(selectedKeys.value)
const record = find(listData.value, { id: value })
emit('update:value', value)
emit('change', record)
}
</script>
<style lang="less" scoped></style>

View File

@ -1,131 +0,0 @@
<template>
<a-modal
:open="modal.open"
:title="modal.title"
:width="480"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-form-item
label="部门名称"
name="name">
<a-input v-model:value="formData.name"></a-input>
</a-form-item>
<a-form-item
label="上级部门"
name="parent_id">
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
</a-form-item>
<a-form-item
label="部门负责人"
name="name">
<a-input v-model:value="formData.name"></a-input>
</a-form-item>
</a-form>
</a-modal>
</template>
<script setup>
import { cloneDeep } from 'lodash-es'
import { ref } from 'vue'
import { config } from '@/config'
import apis from '@/apis'
import { useForm, useModal } from '@/hooks'
const emit = defineEmits(['ok'])
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
const cancelText = ref('取消')
/**
* 新建
*/
function handleCreate() {
showModal({
type: 'create',
title: '新建部门',
})
}
/**
* 编辑
*/
function handleEdit(record = {}) {
showModal({
type: 'edit',
title: '编辑部门',
})
formRecord.value = record
formData.value = cloneDeep(record)
}
/**
* 确定
*/
function handleOk() {
formRef.value
.validateFields()
.then(async (values) => {
try {
showLoading()
const params = {
...values,
}
let result = null
switch (modal.value.type) {
case 'create':
result = await apis.common.create(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.common.update(params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.code) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
}
})
.catch(() => {
hideLoading()
})
}
/**
* 取消
*/
function handleCancel() {
hideModal()
}
/**
* 关闭后
*/
function onAfterClose() {
resetForm()
cancelText.value = '取消'
hideLoading()
}
defineExpose({
handleCreate,
handleEdit,
})
</script>
<style lang="less" scoped></style>

View File

@ -39,7 +39,7 @@
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
添加动态 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading" <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"

View File

@ -1,169 +0,0 @@
<template>
<a-card
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
:style="{
position: 'sticky',
top: appStore.mainOffsetTop,
height: appStore.mainHeight,
}">
<template #title>
<a-input-search placeholder="搜索部门"></a-input-search>
</template>
<x-scrollbar class="pa-8-2">
<a-spin :spinning="loading">
<a-tree
block-node
:selected-keys="selectedKeys"
:tree-data="listData"
:field-names="{ key: 'id', children: 'children' }"
@select="onSelect">
<template #title="{ title }">
<span class="ant-tree-title__name">{{ title }}</span>
<span class="ant-tree-title__actions">
<a-dropdown
:trigger="['click']"
@click.stop>
<x-action-button>
<more-outlined></more-outlined>
</x-action-button>
<template #overlay>
<a-menu>
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
添加子部门
</a-menu-item>
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
编辑
</a-menu-item>
<a-menu-item @click="handleDelete">删除</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</span>
</template>
</a-tree>
<empty
v-if="!listData.length"
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
</a-spin>
</x-scrollbar>
<template #actions>
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
<plus-outlined></plus-outlined>
新建部门
</span>
</template>
</a-card>
<edit-department-dialog
ref="editDepartmentDialogRef"
@ok="onOk"></edit-department-dialog>
</template>
<script setup>
import { useAppStore } from '@/store'
import { ref, watch } from 'vue'
import { usePagination } from '@/hooks'
import apis from '@/apis'
import { Empty, Modal, message } from 'ant-design-vue'
import { config } from '@/config'
import { head, get, find } from 'lodash-es'
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
import EditDepartmentDialog from './EditDepartmentDialog.vue'
const props = defineProps({
value: {
type: String,
default: '',
},
})
const emit = defineEmits(['change', 'update:value'])
const appStore = useAppStore()
const { listData, loading, showLoading, hideLoading } = usePagination()
const editDepartmentDialogRef = ref()
const selectedKeys = ref([props.value])
watch(
() => props.value,
(val) => {
if (val === selectedKeys.value?.[0]) return
selectedKeys.value = [val]
}
)
getList()
/**
* 获取列表
* @returns {Promise<void>}
*/
async function getList() {
try {
showLoading()
const { code, data } = await apis.common.getPageList().catch(() => {
throw new Error()
})
hideLoading()
if (config('http.code.success') === code) {
const { records } = data
listData.value = records
if (listData.value.length) {
selectedKeys.value = [get(head(listData.value), 'id')]
trigger()
}
}
} catch (error) {
hideLoading()
}
}
/**
* 删除
*/
function handleDelete({ id }) {
Modal.confirm({
title: '删除提示',
content: '确认删除?',
okText: '确认',
onOk: () => {
return new Promise((resolve, reject) => {
;(async () => {
try {
const { code } = await apis.common.del(id).catch(() => {
throw new Error()
})
if (config('http.code.success') === code) {
resolve()
message.success('删除成功')
await getList()
}
} catch (error) {
reject()
}
})()
})
},
})
}
function onSelect(keys) {
if (!keys.length) return
selectedKeys.value = keys
trigger()
}
async function onOk() {
await getList()
}
function trigger() {
const value = head(selectedKeys.value)
const record = find(listData.value, { id: value })
emit('update:value', value)
emit('change', record)
}
</script>
<style lang="less" scoped></style>

View File

@ -1,131 +0,0 @@
<template>
<a-modal
:open="modal.open"
:title="modal.title"
:width="480"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-form-item
label="部门名称"
name="name">
<a-input v-model:value="formData.name"></a-input>
</a-form-item>
<a-form-item
label="上级部门"
name="parent_id">
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
</a-form-item>
<a-form-item
label="部门负责人"
name="name">
<a-input v-model:value="formData.name"></a-input>
</a-form-item>
</a-form>
</a-modal>
</template>
<script setup>
import { cloneDeep } from 'lodash-es'
import { ref } from 'vue'
import { config } from '@/config'
import apis from '@/apis'
import { useForm, useModal } from '@/hooks'
const emit = defineEmits(['ok'])
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
const cancelText = ref('取消')
/**
* 新建
*/
function handleCreate() {
showModal({
type: 'create',
title: '新建部门',
})
}
/**
* 编辑
*/
function handleEdit(record = {}) {
showModal({
type: 'edit',
title: '编辑部门',
})
formRecord.value = record
formData.value = cloneDeep(record)
}
/**
* 确定
*/
function handleOk() {
formRef.value
.validateFields()
.then(async (values) => {
try {
showLoading()
const params = {
...values,
}
let result = null
switch (modal.value.type) {
case 'create':
result = await apis.common.create(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.common.update(params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.code) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
}
})
.catch(() => {
hideLoading()
})
}
/**
* 取消
*/
function handleCancel() {
hideModal()
}
/**
* 关闭后
*/
function onAfterClose() {
resetForm()
cancelText.value = '取消'
hideLoading()
}
defineExpose({
handleCreate,
handleEdit,
})
</script>
<style lang="less" scoped></style>

View File

@ -1,154 +1,139 @@
<template> <template>
<a-modal <a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:open="modal.open" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-spin :spinning="spining">
:width="640" <a-form ref="formRef" :model="formData" :rules="formRules">
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.username')"
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="formData.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.password')"
name="password">
<a-input-password
v-model:value="formData.password"
:placeholder="$t('pages.system.user.form.password.placeholder')" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.name')"
name="name">
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="formData.name"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.roles')"
name="roles">
<a-select
v-model:value="formData.roles"
mode="multiple"
style="width: 100%"
:placeholder="$t('pages.system.user.form.roles.placeholder')"
:options="roles"
@change="handleChange"></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.phone')"
type="tel"
name="phone">
<a-input
:placeholder="$t('pages.system.user.form.phone.placeholder')"
type="tel"
v-model:value="formData.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.email')"
type="email"
name="email">
<a-input
:placeholder="$t('pages.system.user.form.email.placeholder')"
type="email"
v-model:value="formData.email"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'招聘岗位'" name="title">
:label="$t('pages.system.user.form.remark')" <a-input :placeholder="'请输入招聘岗位名称'" v-model:value="formData.title"></a-input>
name="remark">
<a-textarea
:placeholder="$t('pages.system.user.form.remark.placeholder')"
v-model:value="formData.remark"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'所属基地'" name="jobAreaId">
:label="$t('pages.system.user.form.status')" <div style="display: flex;justify-content: space-between;">
name="status"> <a-select v-model:value="formData.jobAreaId" allowClear>
<a-radio-group <a-select-option v-for="item in areaList" :value="item.code">{{ item.name
v-model:value="formData.status" }}</a-select-option>
:options="[ </a-select>
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' }, <a-button type="primary" @click="childOpen = true">新增基地</a-button>
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' }, </div>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'岗位要求'" name="introduce">
<a-textarea :placeholder="'请输入岗位要求'" v-model:value="formData.introduce"></a-textarea>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'岗位职责'" name="duty">
<a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.duty"></a-textarea>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'薪资范畴'" name="salary">
<a-input v-model:value="formData.salary" :placeholder="'请输入薪资范畴'" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'岗位排序'" name="sequence">
<a-input-number v-model:value="formData.sequence" :placeholder="'请输入排序'"
style="width: 100%;" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'状态'" name="status">
<a-radio-group v-model:value="formData.status" :options="[
{ label: '启用', value: 'enabled' },
{ label: '停用', value: 'disabled' },
]"></a-radio-group> ]"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-card> </a-card>
</a-form> </a-form>
</a-spin>
<a-modal ref="modalRef" v-model:open="childOpen" :wrap-style="{ overflow: 'hidden' }" @ok="childHandleOk">
<a-card class="mb-8-2">
<a-form ref="areaFormRef" :model="formArea" :rules="areaFormRules">
<a-row :gutter="12">
<a-col :span="24">
<a-form-item :label="'基地名称'" name="name">
<a-input v-model:value="formArea.name" :placeholder="'请输入基地名称'" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'状态'" name="status" style="width: 100%;">
<a-radio-group v-model:value="formArea.status" :options="[
{ label: '启用', value: 'enabled' },
{ label: '停用', value: 'disabled' },
]"></a-radio-group>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
<template #title>
<div ref="modalTitleRef" style="width: 100%; cursor: move">新增基地</div>
</template>
</a-modal>
</a-modal> </a-modal>
</template> </template>
<script setup> <script setup>
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import { ref } from 'vue' import { ref, onBeforeMount } from 'vue'
import { config } from '@/config' import { config } from '@/config'
import apis from '@/apis' import apis from '@/apis'
import { useForm, useModal } from '@/hooks' import { useForm, useModal,useSpining } from '@/hooks'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
const areaFormRef = ref()
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formRecord, formData, formRef, formRules, resetForm } = useForm() const { formRecord, formData, formRef, formRules, resetForm } = useForm()
const { spining,showSpining,hideSpining} = useSpining()
const cancelText = ref(t('button.cancel')) const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const rolesValue = ref([]) const rolesValue = ref([])
const roles = ref([]) const roles = ref([])
const imgUrl = ref('')
const areaList = ref([])
const childOpen = ref(false)
const formArea = ref({ name: '', status: 'enabled' })
formRules.value = { formRules.value = {
name: { required: true, message: t('pages.system.user.form.username.placeholder') }, title: { required: true, message: '请输入岗位名称' },
username: { required: true, message: t('pages.system.user.form.code.placeholder') }, jobAreaId: { required: true, message: '请选择所属基地', trigger: 'change' },
status: { required: true, message: t('pages.system.user.form.status') }, introduce: { required: true, message: '请输入岗位要求' },
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], duty: [{ required: true, message: '请输入岗位职责' }],
salary: [{ required: true, message: '请输入薪资范畴' }],
sequence: [{ required: true, message: '请输入岗位排序' }],
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
}
const areaFormRules = {
name: [{ required: true, message: '请输入基地名称' }],
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
}
const initData = async () => {
try {
showSpining()
const { success, data, total } = await apis.recruitment.getAreasList({ pageSize: 999, page: 1, })
if (config('http.code.success') === success) {
hideSpining()
areaList.value = data.map(item => {
if (item.status === 'enabled') {
return { code: item.id, name: item.name }
}
})
}
} catch (error) {
message.error({ content: error.message })
hideSpining()
} }
/**
* 请求角色
*/
getRole()
/**
* select 选择框
*/
const handleChange = (value) => {
rolesValue.value = value
} }
/** /**
@ -157,26 +142,28 @@ const handleChange = (value) => {
function handleCreate() { function handleCreate() {
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.user.add'), title: '薪资招聘岗位',
}) })
initData()
formData.value.status = 'enabled'
} }
async function getRole() {
const { success, data } = await apis.role.getRoleList().catch(() => { //
throw new Error()
}) const childHandleOk = async () => {
if (!success) { areaFormRef.value.validateFields().then(async (values) => {
return message.error('当前角色信息错误') try {
const params = { ...formArea.value }
const { success } = await apis.recruitment.createAreaItem(params)
if (success) message.success('新增成功')
childOpen.value = false
formArea.value = { name: '', status: 'enabled' }
initData()
} catch (error) {
message.error(error.message)
} }
let roleArr = []
if (data.length) {
data.forEach((item) => {
roleArr.push({
label: item.name,
value: item.id,
}) })
})
}
roles.value = roleArr
} }
/** /**
* 编辑 * 编辑
@ -186,45 +173,38 @@ async function handleEdit(record = {}) {
type: 'edit', type: 'edit',
title: t('pages.system.user.edit'), title: t('pages.system.user.edit'),
}) })
const { data, success } = await apis.users.getUsers(record.id).catch() const { data, success } = await apis.recruitment.getItem(record.id).catch()
if (!success) { if (!success) {
hideModal() hideModal()
return return
} }
let roles = [] formData.value = { ...data }
if (data.roles) { imgUrl.value = config('http.apiBasic') + data.img
roles = formatArr(data.roles, 'edit')
}
data.roles = roles
formRecord.value = data
formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */
function handleOk() { function handleOk() {
formRef.value formRef.value.validateFields().then(async (values) => {
.validateFields()
.then(async (values) => {
try { try {
showLoading() showLoading()
const params = { const params = {
...values, ...values,
roles: formatArr(rolesValue.value), img: formData.value.img,
pushAt: dayjs().format('YYYY-MM-DD'),
type: 'news'
} }
let result = null let result = null
switch (modal.value.type) { switch (modal.value.type) {
case 'create': case 'create':
result = await apis.users.createUsers(params).catch(() => { result = await apis.recruitment.createItem(params).catch((error) => {
throw new Error() throw new Error(error)
}) })
break break
case 'edit': case 'edit':
result = await apis.users.updateUsers(formData.value.id, params).catch(() => { result = await apis.recruitment.updateItem(formData.value.id, params).catch(() => {
throw new Error() throw new Error(error)
}) })
break break
} }
@ -234,45 +214,22 @@ function handleOk() {
emit('ok') emit('ok')
} }
} catch (error) { } catch (error) {
message.error({ content: error.message })
hideLoading() hideLoading()
} }
}) })
.catch(() => { .catch((e) => {
console.log(e)
hideLoading() hideLoading()
}) })
} }
/**
* 对权限组 过数据格式
*/
function formatArr(data, type = '') {
const rolesArr = []
data.forEach((item) => {
roles.value.forEach((r) => {
if (type === 'edit') {
if (item.role_id === r.value) {
rolesArr.push({
value: item.role_id,
label: r.label,
})
return
}
} else if (r.value === item) {
rolesArr.push({
role_id: item,
role_name: r.label,
})
return
}
})
})
return rolesArr
}
/** /**
* 取消 * 取消
*/ */
function handleCancel() { function handleCancel() {
imgUrl.value = ''
hideModal() hideModal()
} }

View File

@ -1,44 +1,27 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="岗位名称" name="title">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入岗位名称" v-model:value="searchFormData.title"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col class="align-right" v-bind="colSpan">
<a-col
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +30,45 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增招聘
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key">
<!--状态--> <template v-if="column.dataIndex === 'introduce'">
<a-tag <a-tooltip :title="record.introduce">
v-if="statusUserTypeEnum.is('activated', record.status)" <div class="text-ellipsis">{{ record.introduce }}</div>
color="processing"> </a-tooltip>
{{ statusUserTypeEnum.getDesc(record.status) }} </template>
</a-tag> <template v-if="column.dataIndex === 'duty'">
<!--状态--> <a-tooltip :title="record.duty">
<a-tag <div class="text-ellipsis">{{ record.duty }}</div>
v-if="statusUserTypeEnum.is('freezed', record.status)" </a-tooltip>
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
</template> </template>
<template v-if="'createAt' === column.key"> <template v-if="'status' === column.dataIndex">
{{ formatUtcDateTime(record.created_at) }} <a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +76,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -124,17 +92,18 @@ import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
defineOptions({ defineOptions({
name: 'recruitment', name: 'homeBanner',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '招聘岗位', dataIndex: 'title', width: 120, },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '所属基地', dataIndex: 'areaName', key: 'title', width: 150 },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '岗位要求', dataIndex: 'introduce', key: 'introduce'},
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '岗位职责', dataIndex: 'duty',ellipsis: true,},
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '薪资范畴', dataIndex: 'salary', width: 120, align: 'center'},
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: '岗位排序', dataIndex: 'sequence', width: 120, align: 'center'},
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 }, { title: '状态', dataIndex: 'status',width:80 , align: 'center'},
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +119,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.recruitment
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -181,7 +150,7 @@ function handleDelete({ id }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
; (async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.recruitment.delItem(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {