feat: 支局长/领导可指定客户经理创建记录

后端 schema: WorkPlanCreate/MiniBusinessCreate/KeyVisitCreate 新增可选 manager_id
后端 API: create 端点支持 manager_id 参数(留空则默认本人)
前端: 三个页面新建弹窗新增「客户经理」下拉(仅支局长/领导可见)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-27 11:17:54 +08:00
parent 576715f990
commit a4904973bf
9 changed files with 51 additions and 9 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ async def create_key_visit(
planned_date=data.planned_date,
planned_visitor=data.planned_visitor,
visit_target=data.visit_target,
manager_id=uuid.UUID(current_user["user_id"]),
manager_id=data.manager_id or uuid.UUID(current_user["user_id"]),
)
init_entry(k, current_user["name"])
db.add(k)
+1 -1
View File
@@ -60,7 +60,7 @@ async def create_mini_business(
amount=data.amount,
follow_up_detail=data.follow_up_detail,
status=data.status,
manager_id=uuid.UUID(current_user["user_id"]),
manager_id=data.manager_id or uuid.UUID(current_user["user_id"]),
expected_revenue_date=data.expected_revenue_date,
)
init_entry(m, current_user["name"])
+1 -1
View File
@@ -58,7 +58,7 @@ async def create_work_plan(
customer_id=data.customer_id,
plan_content=data.plan_content,
plan_date=parse_date(data.plan_date),
manager_id=uuid.UUID(current_user["user_id"]),
manager_id=data.manager_id or uuid.UUID(current_user["user_id"]),
status=data.status,
)
init_entry(wp, current_user["name"])
+1
View File
@@ -11,6 +11,7 @@ class KeyVisitCreate(BaseModel):
planned_date: str = ""
planned_visitor: str = ""
visit_target: str = ""
manager_id: Optional[uuid.UUID] = None
class KeyVisitUpdate(BaseModel):
+1
View File
@@ -10,6 +10,7 @@ class MiniBusinessCreate(BaseModel):
follow_up_detail: str = ""
status: str = "跟进中"
expected_revenue_date: str = ""
manager_id: Optional[uuid.UUID] = None
class MiniBusinessUpdate(BaseModel):
+1
View File
@@ -9,6 +9,7 @@ class WorkPlanCreate(BaseModel):
plan_content: str = ""
plan_date: str # "YYYY-MM-DD"
status: str = "计划中"
manager_id: Optional[uuid.UUID] = None # director can assign to a specific manager
class WorkPlanUpdate(BaseModel):
+15 -2
View File
@@ -10,6 +10,7 @@ const auth = useAuthStore()
const loading = ref(false)
const keyVisits = ref<any[]>([])
const customers = ref<any[]>([])
const managers = ref<any[]>([])
const allUsers = ref<any[]>([])
const plannedVisitors = ref<string[]>([])
@@ -36,9 +37,16 @@ const managerSummary = computed(() => {
})
onMounted(async () => {
await Promise.all([loadItems(), loadCustomers(), loadUsers()])
await Promise.all([loadItems(), loadCustomers(), loadUsers(), loadManagers()])
})
async function loadManagers() {
try {
const res = await api.get('/users/', { params: { role: 'manager' } })
managers.value = res.data || []
} catch (_) {}
}
async function loadUsers() {
try {
const res = await api.get('/users/')
@@ -66,7 +74,7 @@ async function loadItems() {
function openCreate() {
dialogMode.value = 'create'
form.value = { customer_id: '', urgency_level: '一般', description: '', progress_status: '未开始', planned_date: '', planned_visitor: '', visit_target: '' }
form.value = { customer_id: '', urgency_level: '一般', description: '', progress_status: '未开始', planned_date: '', planned_visitor: '', visit_target: '', manager_id: '' }
plannedVisitors.value = []
dialogVisible.value = true
}
@@ -191,6 +199,11 @@ async function quickStatusChange(row: any, newStatus: string) {
<!-- Dialog -->
<el-dialog v-model="dialogVisible" :title="(dialogMode === 'create' ? '新建' : '编辑') + ' 要客拜访'" width="520px">
<el-form label-position="top">
<el-form-item v-if="(auth.isDirector || auth.isLeader) && dialogMode==='create'" label="客户经理">
<el-select v-model="form.manager_id" placeholder="留空则为本人" clearable style="width:100%">
<el-option v-for="m in managers" :key="m.id" :label="m.name" :value="m.id" />
</el-select>
</el-form-item>
<el-form-item label="客户单位">
<el-select v-model="form.customer_id" filterable remote :remote-method="(q: string) => loadCustomers(q)" placeholder="搜索选择客户" style="width:100%">
<el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" />
+15 -2
View File
@@ -10,6 +10,7 @@ const auth = useAuthStore()
const loading = ref(false)
const miniBusiness = ref<any[]>([])
const customers = ref<any[]>([])
const managers = ref<any[]>([])
const dialogVisible = ref(false)
const dialogMode = ref<'create' | 'edit'>('create')
@@ -34,9 +35,16 @@ const managerSummary = computed(() => {
})
onMounted(async () => {
await Promise.all([loadItems(), loadCustomers()])
await Promise.all([loadItems(), loadCustomers(), loadManagers()])
})
async function loadManagers() {
try {
const res = await api.get('/users/', { params: { role: 'manager' } })
managers.value = res.data || []
} catch (_) {}
}
async function loadCustomers(q?: string) {
try {
const params: any = { page_size: 100 }
@@ -57,7 +65,7 @@ async function loadItems() {
function openCreate() {
dialogMode.value = 'create'
form.value = { customer_id: '', product_type: '', amount: '', follow_up_detail: '', status: '跟进中', expected_revenue_date: '' }
form.value = { customer_id: '', product_type: '', amount: '', follow_up_detail: '', status: '跟进中', expected_revenue_date: '', manager_id: '' }
dialogVisible.value = true
}
@@ -171,6 +179,11 @@ async function quickStatusChange(row: any, newStatus: string) {
<!-- Dialog -->
<el-dialog v-model="dialogVisible" :title="(dialogMode === 'create' ? '新建' : '编辑') + ' 小微商机'" width="500px">
<el-form label-position="top">
<el-form-item v-if="(auth.isDirector || auth.isLeader) && dialogMode==='create'" label="客户经理">
<el-select v-model="form.manager_id" placeholder="留空则为本人" clearable style="width:100%">
<el-option v-for="m in managers" :key="m.id" :label="m.name" :value="m.id" />
</el-select>
</el-form-item>
<el-form-item label="客户单位">
<el-select v-model="form.customer_id" filterable remote :remote-method="(q: string) => loadCustomers(q)" placeholder="搜索选择客户" style="width:100%">
<el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" />
+15 -2
View File
@@ -10,6 +10,7 @@ const auth = useAuthStore()
const loading = ref(false)
const workPlans = ref<any[]>([])
const customers = ref<any[]>([])
const managers = ref<any[]>([])
const dialogVisible = ref(false)
const dialogMode = ref<'create' | 'edit'>('create')
@@ -34,9 +35,16 @@ const managerSummary = computed(() => {
})
onMounted(async () => {
await Promise.all([loadPlans(), loadCustomers()])
await Promise.all([loadPlans(), loadCustomers(), loadManagers()])
})
async function loadManagers() {
try {
const res = await api.get('/users/', { params: { role: 'manager' } })
managers.value = res.data || []
} catch (_) {}
}
async function loadCustomers(q?: string) {
try {
const params: any = { page_size: 100 }
@@ -57,7 +65,7 @@ async function loadPlans() {
function openCreate() {
dialogMode.value = 'create'
form.value = { customer_id: '', plan_content: '', plan_date: todayStr(), status: '计划中' }
form.value = { customer_id: '', plan_content: '', plan_date: todayStr(), status: '计划中', manager_id: '' }
dialogVisible.value = true
}
@@ -169,6 +177,11 @@ async function quickStatusChange(row: any, newStatus: string) {
<!-- Dialog -->
<el-dialog v-model="dialogVisible" :title="(dialogMode === 'create' ? '新建' : '编辑') + ' 工作计划'" width="500px">
<el-form label-position="top">
<el-form-item v-if="(auth.isDirector || auth.isLeader) && dialogMode==='create'" label="客户经理">
<el-select v-model="form.manager_id" placeholder="留空则为本人" clearable style="width:100%">
<el-option v-for="m in managers" :key="m.id" :label="m.name" :value="m.id" />
</el-select>
</el-form-item>
<el-form-item label="客户单位">
<el-select v-model="form.customer_id" filterable remote :remote-method="(q: string) => loadCustomers(q)" placeholder="搜索选择客户" style="width:100%">
<el-option v-for="c in customers" :key="c.id" :label="c.name" :value="c.id" />