This commit is contained in:
张成
2025-11-26 18:39:15 +08:00
parent 771dc60607
commit d5d8069573
15 changed files with 2346 additions and 1593 deletions

View File

@@ -1,8 +1,12 @@
<template>
<div class="content-view">
<div class="table-head-tool">
<Button type="primary" @click="showAddWarp">新增账号</Button>
<Button type="success" @click="batchParseLocation" :loading="batchParseLoading" class="ml10">批量解析位置</Button>
<div>
<Button type="primary" @click="showAddWarp">新增账号</Button>
<Button type="success" @click="batchParseLocation" :loading="batchParseLoading"
class="ml10">批量解析位置</Button>
</div>
<Form ref="formInline" :model="gridOption.param.seachOption" inline :label-width="80">
<FormItem :label-width="20" class="flex">
<Select v-model="gridOption.param.seachOption.key" style="width: 120px"
@@ -37,8 +41,13 @@
<tables :columns="listColumns" :value="gridOption.data" :pageOption="gridOption.param.pageOption"
@changePage="query"></tables>
</div>
<editModal ref="editModal" :columns="editColumns" :rules="gridOption.rules" @on-save="handleSaveSuccess">
<!-- 新增弹窗只包含必填字段 -->
<editModal ref="editModal" :columns="addColumns" :rules="gridOption.rules" @on-save="handleSaveSuccess">
</editModal>
<!-- 编辑组件使用 FloatPanel包含所有字段 -->
<PlaAccountEdit ref="accountEdit" @on-save="handleSaveSuccess" />
<!-- 简历详情弹窗 -->
<Modal v-model="resumeModal.visible" :title="resumeModal.title" width="900" :footer-hide="true">
@@ -216,8 +225,12 @@
<script>
import plaAccountServer from '@/api/profile/pla_account_server.js'
import jobTypesServer from '@/api/work/job_types_server.js'
import PlaAccountEdit from './pla_account_edit.vue'
export default {
components: {
PlaAccountEdit
},
data() {
let rules = {}
rules["name"] = [{ required: true, message: '请填写账户名', trigger: 'blur' }]
@@ -257,6 +270,19 @@ export default {
data: [],
rules: rules
},
// 新增时只显示必填字段
addColumns: [
{ title: '账户名', key: 'name', type: 'text', required: true },
{ title: '设备SN码', key: 'sn_code', type: 'text', required: true },
{
title: '平台', key: 'platform_type', com: 'Select', required: true, source: [
{ key: '1', value: 'Boss直聘' },
{ key: '2', value: '猎聘' }
]
},
{ title: '登录名', key: 'login_name', com: 'Input', required: true },
{ title: '密码', key: 'pwd', com: 'Password', required: true },
],
listColumns: [
{ title: 'ID', key: 'id', minWidth: 80 },
{ title: '账户名', key: 'name', minWidth: 150 },
@@ -417,54 +443,6 @@ export default {
return window.framework.uiTool.getBtn(h, btns)
},
}
],
editColumns: [
{ title: '账户名', key: 'name', type: 'text', required: true },
{ title: '设备SN码', key: 'sn_code', type: 'text', required: true },
{
title: '平台', key: 'platform_type', type: 'select', required: true, options: [
{ value: '1', label: 'Boss直聘' },
{ value: '2', label: '猎聘' }
]
},
{ title: '登录名', key: 'login_name', type: 'text', required: true },
{ title: '密码', key: 'pwd', type: 'password' },
{ title: '搜索关键词', key: 'keyword', type: 'text' },
{ title: '启用状态', key: 'is_enabled', type: 'switch' },
{ title: '在线状态', key: 'is_online', type: 'switch' },
{
title: '职位类型',
key: 'job_type_id',
type: 'select',
required: false,
options: this.jobTypeOptions || []
},
{ title: '用户地址', key: 'user_address', type: 'text', placeholder: '请输入用户地址,如:北京市朝阳区' },
// 自动投递配置
{
title: '自动投递', key: 'auto_deliver', "com": "Radio", options: [
{ value: 1, label: '开启' },
{ value: 0, label: '关闭' }
],
},
{ title: '最低薪资(元)', key: 'min_salary', type: 'number', placeholder: '最低薪资0表示不限制' },
{ title: '最高薪资(元)', key: 'max_salary', type: 'number', placeholder: '最高薪资0表示不限制' },
// 自动沟通配置
{
title: '自动沟通', key: 'auto_chat', "com": "Radio", options: [
{ value: 1, label: '开启' },
{ value: 0, label: '关闭' }
],
},
{ title: '沟通间隔(分钟)', key: 'chat_interval', type: 'number', placeholder: '沟通间隔时间默认30分钟' },
{ title: '自动回复', key: 'auto_reply', type: 'switch' },
// 自动活跃配置
{
title: '自动活跃', key: 'auto_active', "com": "Radio", options: [
{ value: 1, label: '开启' },
{ value: 0, label: '关闭' }
],
},
]
}
},
@@ -481,18 +459,11 @@ export default {
})
},
showAddWarp() {
// 新增使用简单的 editModal只包含必填字段
this.$refs.editModal.showModal()
},
showEditWarp(row) {
// 将布尔字段从 0/1 转换为 true/false以便开关组件正确显示
const editData = { ...row }
const booleanFields = ['is_enabled', 'is_online', 'auto_deliver', 'auto_chat', 'auto_reply', 'auto_active']
booleanFields.forEach(field => {
if (editData[field] !== undefined && editData[field] !== null) {
editData[field] = Boolean(editData[field])
}
})
this.$refs.editModal.showModal(editData)
this.$refs.accountEdit.showEdit(row)
},
toggleEnabled(row, value) {
const action = value ? '启用' : '禁用'
@@ -517,21 +488,7 @@ export default {
})
},
loadJobTypes() {
jobTypesServer.getAll().then(res => {
if (res.code === 0 && res.data) {
this.jobTypeOptions = res.data.map(item => ({
value: item.id,
label: item.name
}))
// 更新 editColumns 中的选项
const jobTypeColumn = this.gridOption.editColumns.find(col => col.key === 'job_type_id')
if (jobTypeColumn) {
jobTypeColumn.options = this.jobTypeOptions
}
}
}).catch(err => {
console.error('加载职位类型失败:', err)
})
// 职位类型选项已移到编辑组件中加载
},
stopTasks(row) {
this.$Modal.confirm({
@@ -571,25 +528,12 @@ export default {
},
async handleSaveSuccess({ data }) {
try {
// 将布尔字段从 true/false 转换为 1/0
const saveData = { ...data }
const booleanFields = ['is_enabled', 'is_online', 'auto_deliver', 'auto_chat', 'auto_reply', 'auto_active']
booleanFields.forEach(field => {
if (saveData[field] !== undefined && saveData[field] !== null) {
saveData[field] = saveData[field] ? 1 : 0
}
})
// 根据是否有 id 判断是新增还是更新
if (saveData.id) {
await plaAccountServer.update(saveData)
} else {
await plaAccountServer.add(saveData)
// 如果是新增(来自 editModaldata 只包含必填字段,直接保存
if (data && !data.id) {
await plaAccountServer.add(data)
this.$Message.success('保存成功!')
}
this.$Message.success('保存成功!')
// 编辑时由 FloatPanel 组件PlaAccountEdit处理保存这里只刷新列表
this.query(this.gridOption.param.pageOption.page)
} catch (error) {
console.error('保存失败:', error)
@@ -702,7 +646,7 @@ export default {
// 批量解析位置
async batchParseLocation() {
const selectedRows = this.gridOption.data.filter(row => row.user_address && row.user_address.trim() !== '')
if (selectedRows.length === 0) {
this.$Message.warning('当前页面没有已设置地址的账号')
return
@@ -721,20 +665,20 @@ export default {
const result = res.data
const successCount = result.success || 0
const failedCount = result.failed || 0
let message = `批量解析完成:成功 ${successCount}`
if (failedCount > 0) {
message += `,失败 ${failedCount}`
}
this.$Message.success(message)
// 如果有失败的,显示详细信息
if (failedCount > 0 && result.details) {
const failedDetails = result.details.filter(d => !d.success)
console.log('解析失败的账号:', failedDetails)
}
this.query(this.gridOption.param.pageOption.page)
} else {
this.$Message.error(res.message || '批量解析失败')