即将修改网站-联系我们-混乱中

This commit is contained in:
qingyu 2025-06-24 10:20:53 +08:00
parent bbd5816522
commit c561186c46
2 changed files with 326 additions and 229 deletions

View File

@ -1,154 +1,191 @@
<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-row :gutter="12">
<a-col :span="12"> <a-col :span="24">
<a-form-item <a-form-item :label="'产品名称'" name="title">
:label="$t('pages.system.user.form.username')" <a-input :placeholder="'请输入产品名称'" v-model:value="formData.title"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="formData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item <a-form-item :label="'产品类别'" name="categoryID">
:label="$t('pages.system.user.form.password')" <div style="display: flex;justify-content: space-between;">
name="password"> <a-select v-model:value="formData.categoryID" allowClear>
<a-input-password <a-select-option v-for="item in areaList" :value="item.code">{{ item.name }}</a-select-option>
v-model:value="formData.password" </a-select>
:placeholder="$t('pages.system.user.form.password.placeholder')" /> <a-button type="primary" @click="childOpen = true">新增产品类别</a-button>
</div>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> <a-col :span="24">
<a-row :gutter="12"> <a-form-item :label="'原料组成'" name="compose">
<a-col :span="12"> <a-textarea :placeholder="'请输入岗位要求'" v-model:value="formData.compose"></a-textarea>
<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-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item <a-form-item :label="'适用对象'" name="target">
:label="$t('pages.system.user.form.roles')" <a-textarea :placeholder="'请输入岗位职责'" v-model:value="formData.target"></a-textarea>
name="roles"> </a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'功能特点'" name="feature">
<a-select <a-select
v-model:value="formData.roles" v-model:value="formData.feature"
mode="multiple" mode="tags"
style="width: 100%" :placeholder="'请输入功能特点,按回车分隔'"
:placeholder="$t('pages.system.user.form.roles.placeholder')" :token-separators="[',']"
:options="roles" style="width: 100%;"
@change="handleChange"></a-select> />
</a-form-item> </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>
<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-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item
:label="$t('pages.system.user.form.remark')" v-for="(item, index) in formData.standard"
name="remark"> :key="index"
<a-textarea :label="`产品标准 ${index + 1}`">
:placeholder="$t('pages.system.user.form.remark.placeholder')" <a-input
v-model:value="formData.remark"></a-textarea> v-model:value="item.label"
placeholder="请输入标准名称label"
class="inputPhone"
/>
<a-input
v-model:value="item.value"
placeholder="请输入标准值value"
class="inputPhone"
style="margin-top: 8px"
/>
<a-button
danger
@click="removeStandard(index)"
size="small"
style="margin-top: 8px">
删除
</a-button>
</a-form-item>
<a-form-item>
<a-button type="dashed" block @click="addStandard">
新增产品标准
</a-button>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item v-for="(img, index) in formData.images" :key="index" :label="`产品图片 ${index + 1}`">
<x-upload-image v-model="formData.images[index]" @imgChange="(value) => imgChange(index, value)" />
<a-button danger @click="removeImage(index)" size="small">删除</a-button>
</a-form-item>
<a-form-item>
<a-button type="dashed" block @click="addImage">
新增产品图片
</a-button>
</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="sequence">
:label="$t('pages.system.user.form.status')" <a-input-number v-model:value="formData.sequence" :placeholder="'请输入排序'" style="width: 100%;" />
name="status"> </a-form-item>
<a-radio-group </a-col>
v-model:value="formData.status" <a-col :span="24">
:options="[ <a-form-item :label="'状态'" name="status">
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' }, <a-radio-group v-model:value="formData.status" :options="[
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' }, { label: '启用', value: 'enabled' },
]"></a-radio-group> { label: '停用', value: 'disabled' },]"></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') }, categoryID: { required: true, message: '请选择产品类别', trigger: 'change' },
status: { required: true, message: t('pages.system.user.form.status') }, compose: { required: true, message: '请选择产品适用对象', trigger: 'change' },
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], feature: [{ required: true, message: '请输入产品功能特点' }],
standard: [{ required: true, message: '请输入产品标准' }],
images: [{ required: true, message: '请上传产品图片' }],
sequence: [{ required: true, message: '请输入产品排序' }],
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
} }
const areaFormRules = {
/** categoryIDName: [{ required: true, message: '请输入产品类别' }],
* 请求角色 composeName: [{ required: true, message: '请输入产品适用对象' }],
*/ status: [{ required: true, message: '请选择状态', trigger: 'change' }],
getRole() }
const initData = async () => {
/** try {
* select 选择框 showSpining()
*/ const { success, data, total } = await apis.products.getAreasList({ pageSize: 999, page: 1, })
const handleChange = (value) => { if (config('http.code.success') === success) {
rolesValue.value = value 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()
}
} }
/** /**
@ -157,26 +194,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 +225,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 +266,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()
} }
@ -288,6 +297,28 @@ defineExpose({
handleCreate, handleCreate,
handleEdit, handleEdit,
}) })
//
function addStandard() {
formData.value.standard.push({ label: '', value: '' })
}
//
function removeStandard(index) {
if (formData.value.standard.length > 1) {
formData.value.standard.splice(index, 1)
}
}
//
function addImage() {
formData.value.images.push('')
}
//
function removeImage(index) {
if (formData.value.images.length > 1) {
formData.value.images.splice(index, 1)
}
}
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped></style>

View File

@ -45,21 +45,32 @@
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange"> :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'introduce'"> <template v-if="column.dataIndex === 'title'">
<a-tooltip :title="record.introduce"> <a-tooltip :title="record.title">
<div class="text-ellipsis">{{ record.introduce }}</div> <div class="text-ellipsis">{{ record.title }}</div>
</a-tooltip> </a-tooltip>
</template> </template>
<template v-if="column.dataIndex === 'duty'"> <template v-if="column.dataIndex === 'categoryID'">
<a-tooltip :title="record.duty"> <a-tooltip :title="record.categoryID">
<div class="text-ellipsis">{{ record.duty }}</div> <div class="text-ellipsis">{{ record.categoryID }}</div>
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'compose'">
<a-tooltip :title="record.compose">
<div class="text-ellipsis">{{ record.compose }}</div>
</a-tooltip> </a-tooltip>
</template> </template>
<template v-if="column.dataIndex === 'target'">
<a-tooltip :title="record.target">
<div class="text-ellipsis">{{ record.target }}</div>
</a-tooltip>
</template>
<template v-if="'status' === column.dataIndex"> <template v-if="'status' === column.dataIndex">
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag> <a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</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>
@ -91,21 +102,66 @@ import { usePagination } from '@/hooks'
import EditDialog from './components/EditDialog.vue' 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'
import { delProductsItem, getProductsList } from '@/apis/modules/products'
defineOptions({ defineOptions({
name: 'homeBanner', name: 'components',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
// const columns = [
// { title: '', dataIndex: 'title', width: 120, },
// { title: '', dataIndex: 'categoryID', key: 'categoryID', width: 120 },
// { title: '', dataIndex: 'compose', key: 'compose',width: 120},
// { title: '', dataIndex: 'target',width: 120},
// { title: '', dataIndex: 'feature', width: 120, align: 'center'},
// { title: '', dataIndex: 'standard', width: 120, align: 'center'},
// { title: '', dataIndex: 'images', width: 120, align: 'center'},
// { title: '', dataIndex: 'sequence', width: 120, align: 'center'},
// { title: '', dataIndex: 'status',width:120 , align: 'center'},
// { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
// ]
const columns = [ const columns = [
{ title: '招聘岗位', dataIndex: 'title', width: 120, }, { title: '产品名称', dataIndex: 'title', width: 120 },
{ title: '所属基地', dataIndex: 'areaName', key: 'title', width: 150 }, { title: '产品类别', dataIndex: 'categoryID', key: 'categoryID', width: 120 },
{ title: '岗位要求', dataIndex: 'introduce', key: 'introduce'}, { title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 },
{ title: '岗位职责', dataIndex: 'duty',ellipsis: true,}, { title: '适用对象', dataIndex: 'target', width: 120 },
{ title: '薪资范畴', dataIndex: 'salary', width: 120, align: 'center'},
{ title: '岗位排序', dataIndex: 'sequence', width: 120, align: 'center'}, {
{ title: '状态', dataIndex: 'status',width:80 , align: 'center'}, title: '功能特点',
dataIndex: 'feature',
width: 120,
align: 'center',
customRender: ({ text }) => Array.isArray(text) ? text.join(', ') : ''
},
{
title: '产品标准',
dataIndex: 'standard',
width: 120,
align: 'center',
customRender: ({ text }) => Array.isArray(text)
? text.map(item => `${item.label}: ${item.value}`).join(', ')
: ''
},
{
title: '产品图片',
dataIndex: 'images',
width: 120,
align: 'center',
customRender: ({ text }) => {
if (Array.isArray(text) && text.length > 0) {
return `<img src="${text[0]}" alt="产品图" style="width:40px;height:40px;object-fit:cover;" />`
}
return '-'
}
},
{ title: '产品排序', dataIndex: 'sequence', width: 120, align: 'center' },
{ title: '产品状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, 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 } =
usePagination() usePagination()
@ -119,8 +175,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.recruitment const { success, data, total } = await apis.products
.getDataList({ .getProductsList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -150,7 +206,7 @@ function handleDelete({ id }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
; (async () => { ; (async () => {
try { try {
const { success } = await apis.recruitment.delItem(id).catch(() => { const { success } = await apis.products.delProductsItem(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
@ -198,6 +254,16 @@ async function onOk() {
message.success(t('component.message.success.delete')) message.success(t('component.message.success.delete'))
await getPageList() await getPageList()
} }
function addImage() {
images.value.push('')
}
function removeImage(index) {
if (images.value.length > 1) {
images.value.splice(index, 1)
}
}
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped></style>