|
@@ -26,6 +26,8 @@ import axios from 'axios';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { successMessage } from '../../../utils/message';
|
|
|
import BatchTagsDialog from './components/BatchTagsDialog.vue';
|
|
|
+import * as api from './api';
|
|
|
+import { ElMessageBox } from 'element-plus';
|
|
|
|
|
|
const PermissionDrawerCom = defineAsyncComponent(() => import('./components/RoleDrawer.vue'));
|
|
|
|
|
@@ -72,6 +74,106 @@ async function generateQRCode(row: { id: string | number }) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 检查职位信息是否完整
|
|
|
+function checkPositionComplete(row: any): { isComplete: boolean; missing: string[] } {
|
|
|
+ const required = [
|
|
|
+ { field: 'title', name: '职位名称' },
|
|
|
+ { field: 'job_type', name: '职位类型' },
|
|
|
+ { field: 'salary_range', name: '薪资范围' },
|
|
|
+ { field: 'location', name: '工作地点' },
|
|
|
+ { field: 'department', name: '所属部门' },
|
|
|
+ { field: 'requirements', name: '职位要求' },
|
|
|
+ { field: 'description', name: '职位描述' },
|
|
|
+ { field: 'end_date', name: '截止日期' }
|
|
|
+ ];
|
|
|
+
|
|
|
+ const missing = required
|
|
|
+ .filter(({ field }) => !row[field] || (typeof row[field] === 'string' && row[field].trim() === ''))
|
|
|
+ .map(({ name }) => name);
|
|
|
+
|
|
|
+ return {
|
|
|
+ isComplete: missing.length === 0,
|
|
|
+ missing
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+// 发布职位功能
|
|
|
+async function publishPosition(row: any) {
|
|
|
+ try {
|
|
|
+ const action = row.status === 2 ? '重新发布' : '发布';
|
|
|
+
|
|
|
+ // 检查职位信息是否完整
|
|
|
+ const { isComplete, missing } = checkPositionComplete(row);
|
|
|
+ if (!isComplete) {
|
|
|
+ await ElMessageBox.alert(
|
|
|
+ `职位信息不完整,缺少以下必填信息:\n${missing.join('、')}\n\n请先完善职位信息后再发布。`,
|
|
|
+ '职位信息不完整',
|
|
|
+ {
|
|
|
+ confirmButtonText: '去完善',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ );
|
|
|
+ // 跳转到编辑页面
|
|
|
+ router.push(`/position/detail?id=${row.id}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查截止日期是否过期
|
|
|
+ if (row.end_date && new Date(row.end_date) < new Date()) {
|
|
|
+ const result = await ElMessageBox.confirm(
|
|
|
+ `职位截止日期已过期(${row.end_date}),是否要更新截止日期后再发布?`,
|
|
|
+ '截止日期已过期',
|
|
|
+ {
|
|
|
+ confirmButtonText: '更新并发布',
|
|
|
+ cancelButtonText: '仍要发布',
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ if (result === 'confirm') {
|
|
|
+ // 跳转到编辑页面更新截止日期
|
|
|
+ router.push(`/position/detail?id=${row.id}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const confirmText = row.status === 2
|
|
|
+ ? `确定要重新发布职位 "${row.title}" 吗?`
|
|
|
+ : `确定要发布职位 "${row.title}" 吗?发布后求职者即可看到此职位。`;
|
|
|
+
|
|
|
+ // 确认发布对话框
|
|
|
+ await ElMessageBox.confirm(
|
|
|
+ confirmText,
|
|
|
+ `确认${action}`,
|
|
|
+ {
|
|
|
+ confirmButtonText: `确定${action}`,
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ // 调用发布API
|
|
|
+ const response = await api.PublishPosition({
|
|
|
+ job_id: row.id,
|
|
|
+ tenant_id: 1
|
|
|
+ });
|
|
|
+
|
|
|
+ if (response.code === 2000) {
|
|
|
+ successMessage(`职位${action}成功`);
|
|
|
+ // 刷新列表数据
|
|
|
+ crudExpose.doRefresh();
|
|
|
+ } else {
|
|
|
+ ElMessage.error(response.msg || `${action}失败`);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel' && error !== 'close') {
|
|
|
+ console.error('发布职位失败:', error);
|
|
|
+ ElMessage.error('操作失败,请稍后重试');
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 创建 crud 配置
|
|
|
const { crudBinding, crudRef, crudExpose } = useFs({
|
|
|
createCrudOptions,
|
|
@@ -80,6 +182,7 @@ const { crudBinding, crudRef, crudExpose } = useFs({
|
|
|
RoleMenuBtn,
|
|
|
RoleMenuField,
|
|
|
generateQRCode,
|
|
|
+ publishPosition,
|
|
|
router,
|
|
|
$message: {
|
|
|
warning: (msg: string) => successMessage(msg)
|