feat: 订单详情支持分配陪诊师,列表展示累计接单
This commit is contained in:
@@ -30,6 +30,12 @@ export const escortApi = {
|
||||
body,
|
||||
}),
|
||||
|
||||
assign: (id: string, employeeId: string) =>
|
||||
request<{ record: EscortRecord }>(`/health/escort-record/${id}/assign`, {
|
||||
method: 'POST',
|
||||
body: { employeeId },
|
||||
}),
|
||||
|
||||
updateStatus: (id: string, status: string, reason?: string) =>
|
||||
request<{ record: EscortRecord; deleted?: boolean }>(`/health/escort-record/${id}/status`, {
|
||||
method: 'PATCH',
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
|
||||
<template #cell(service)="{ item }">
|
||||
<div>服务年限:{{ item.work?.workYears || 0 }} 年</div>
|
||||
<p class="text-muted mb-0 fs-12">累计接单:{{ item.attendantInfo?.orderCount || 0 }}</p>
|
||||
</template>
|
||||
|
||||
<template #cell(area)="{ item }">
|
||||
@@ -499,7 +500,8 @@
|
||||
</BCol>
|
||||
<BCol v-if="levelForm.grade === 'diamond'" md="6">
|
||||
<label class="form-label">星级</label>
|
||||
<BFormSelect v-model.number="levelForm.star">
|
||||
<!-- 选项 value 绑定为数字,BFormSelect 原样回传,无需 .number 修饰符 -->
|
||||
<BFormSelect v-model="levelForm.star">
|
||||
<option v-for="n in 6" :key="n - 1" :value="n - 1">{{ n - 1 === 0 ? '无' : `${n - 1} 星` }}</option>
|
||||
</BFormSelect>
|
||||
</BCol>
|
||||
@@ -583,14 +585,17 @@ const {
|
||||
load,
|
||||
search,
|
||||
} = useTableQuery<Employee>(
|
||||
// 接口返回 { employees, total },表组件约定 { items, total },这里做一次映射
|
||||
(p, size) =>
|
||||
employeeApi.list({
|
||||
page: p,
|
||||
pageSize: size,
|
||||
keyword: filters.keyword.trim() || undefined,
|
||||
role: filters.role || undefined,
|
||||
status: filters.status || undefined,
|
||||
}),
|
||||
employeeApi
|
||||
.list({
|
||||
page: p,
|
||||
pageSize: size,
|
||||
keyword: filters.keyword.trim() || undefined,
|
||||
role: filters.role || undefined,
|
||||
status: filters.status || undefined,
|
||||
})
|
||||
.then((d) => ({ items: d.employees, total: d.total })),
|
||||
// 同页两个列表,页码监听由原有 watch 手动控制
|
||||
{ autoWatch: false }
|
||||
)
|
||||
@@ -616,7 +621,7 @@ const exportEmployees = async () => {
|
||||
)
|
||||
exportCsv(
|
||||
`attendants-${today()}.csv`,
|
||||
['工号', '姓名', '手机号', '邮箱', '角色', '职称/部门', '状态', '工作年限', '服务区域', '擅长领域', '简介'],
|
||||
['工号', '姓名', '手机号', '邮箱', '角色', '职称/部门', '状态', '工作年限', '累计接单', '服务区域', '擅长领域', '简介'],
|
||||
items.map((item) => [
|
||||
item.employeeNo || '',
|
||||
item.profile?.name || '',
|
||||
@@ -626,6 +631,7 @@ const exportEmployees = async () => {
|
||||
[item.work?.title, item.work?.department].filter(Boolean).join(' / '),
|
||||
EMPLOYEE_STATUS_LABELS[item.status || ''] || item.status || '',
|
||||
item.work?.workYears ?? 0,
|
||||
item.attendantInfo?.orderCount ?? 0,
|
||||
(item.attendantInfo?.serviceAreas || []).join('、'),
|
||||
(item.attendantInfo?.specialties || []).join('、'),
|
||||
item.introduction || '',
|
||||
@@ -739,12 +745,14 @@ const {
|
||||
search: runApplicationSearch,
|
||||
} = useTableQuery<AttendantApplication>(
|
||||
(p, size) =>
|
||||
attendantApplicationApi.list({
|
||||
page: p,
|
||||
pageSize: size,
|
||||
status: appFilters.status || undefined,
|
||||
keyword: appFilters.keyword.trim() || undefined,
|
||||
}),
|
||||
attendantApplicationApi
|
||||
.list({
|
||||
page: p,
|
||||
pageSize: size,
|
||||
status: appFilters.status || undefined,
|
||||
keyword: appFilters.keyword.trim() || undefined,
|
||||
})
|
||||
.then((d) => ({ items: d.applications, total: d.total })),
|
||||
{ autoWatch: false }
|
||||
)
|
||||
|
||||
|
||||
+31
-26
@@ -49,7 +49,7 @@
|
||||
@click="openAssign"
|
||||
>
|
||||
<Icon icon="user-check" class="me-1" />
|
||||
{{ record.attendant?.id || record.attendant?.name ? '更换陪诊师' : '指派陪诊师' }}
|
||||
分配陪诊师
|
||||
</BButton>
|
||||
<BButton v-if="canRecordOffline" variant="success" :disabled="actionLoading" @click="openPayment">
|
||||
线下收款补录
|
||||
@@ -333,7 +333,7 @@
|
||||
<BButton variant="primary" @click="router.replace('/orders')">返回订单列表</BButton>
|
||||
</div>
|
||||
|
||||
<BModal v-model="assignVisible" title="指派陪诊师" hide-footer>
|
||||
<BModal v-model="assignVisible" title="分配陪诊师" hide-footer>
|
||||
<div v-if="assignLoading" class="text-center py-4">
|
||||
<BSpinner variant="primary" />
|
||||
</div>
|
||||
@@ -348,15 +348,19 @@
|
||||
</option>
|
||||
</BFormSelect>
|
||||
</BFormGroup>
|
||||
<BAlert v-if="assignTarget && !assignTarget.userId" variant="warning" show class="py-2 fs-12 mb-3">
|
||||
该陪诊师未关联登录账号,指派后其无法在小程序端看到该订单。
|
||||
<BAlert v-if="assignTarget && !assignTarget.userId" variant="danger" show class="py-2 fs-12 mb-3">
|
||||
该陪诊师未关联登录账号,无法接收订单,请先绑定账号。
|
||||
</BAlert>
|
||||
<p class="text-muted fs-12 mb-0">指派后陪诊师可在小程序端查看并处理该订单。</p>
|
||||
<p class="text-muted fs-12 mb-0">分配后陪诊师可在小程序端查看并处理该订单。</p>
|
||||
</template>
|
||||
<div class="d-flex justify-content-end gap-2 mt-4">
|
||||
<BButton variant="light" @click="assignVisible = false">取消</BButton>
|
||||
<BButton variant="primary" :disabled="assignSubmitting || !assignTarget" @click="submitAssign">
|
||||
{{ assignSubmitting ? '提交中...' : '确认指派' }}
|
||||
<BButton
|
||||
variant="primary"
|
||||
:disabled="assignSubmitting || !assignTarget || !assignTarget.userId"
|
||||
@click="submitAssign"
|
||||
>
|
||||
{{ assignSubmitting ? '提交中...' : '确认分配' }}
|
||||
</BButton>
|
||||
</div>
|
||||
</template>
|
||||
@@ -509,9 +513,10 @@ const canRecordOffline = computed(() => {
|
||||
&& ['pending', 'confirmed'].includes(record.value.status || '')
|
||||
})
|
||||
|
||||
// 指派陪诊师:仅未进入取消流程且服务未结束时允许
|
||||
// 分配陪诊师:仅未分配且未进入取消流程的进行中订单允许
|
||||
const canAssignAttendant = computed(() => {
|
||||
if (!record.value) return false
|
||||
if (record.value.attendant?.id || record.value.attendant?.name) return false
|
||||
return (record.value.cancelStatus || 'none') === 'none'
|
||||
&& ['pending', 'confirmed', 'in_progress'].includes(record.value.status || '')
|
||||
})
|
||||
@@ -523,16 +528,26 @@ const attendants = ref<Employee[]>([])
|
||||
const assignTarget = ref<Employee | null>(null)
|
||||
|
||||
const openAssign = async () => {
|
||||
const currentId = record.value?.attendant?.id
|
||||
assignTarget.value = currentId
|
||||
? attendants.value.find((emp) => emp.userId && String(emp.userId) === String(currentId)) || null
|
||||
: null
|
||||
assignTarget.value = null
|
||||
assignVisible.value = true
|
||||
if (!attendants.value.length) {
|
||||
assignLoading.value = true
|
||||
try {
|
||||
const data = await employeeApi.list({ page: 1, pageSize: 100, role: 'attendant', status: 'active' })
|
||||
attendants.value = data.employees
|
||||
// 分页拉全量在职陪诊师:单页有上限,只拉一页会静默漏人
|
||||
const fetched: Employee[] = []
|
||||
let page = 1
|
||||
let total = Number.POSITIVE_INFINITY
|
||||
while (fetched.length < total && page <= 20) {
|
||||
const data = await employeeApi.list({ page, pageSize: 100, role: 'attendant', status: 'active' })
|
||||
total = data.total
|
||||
fetched.push(...data.employees)
|
||||
if (!data.employees.length) break
|
||||
page += 1
|
||||
}
|
||||
// 实习陪诊师不可被指派,后端同样会拦截
|
||||
attendants.value = fetched.filter(
|
||||
(emp) => (emp.attendantInfo?.stage || 'certified') !== 'intern'
|
||||
)
|
||||
} catch {
|
||||
// 错误提示由请求层统一弹出
|
||||
} finally {
|
||||
@@ -543,20 +558,10 @@ const openAssign = async () => {
|
||||
|
||||
const submitAssign = async () => {
|
||||
if (!record.value || !assignTarget.value) return
|
||||
const emp = assignTarget.value
|
||||
// 后端 attendant.sex 枚举仅 none/male/female,员工档案里的 other 需归一到 none
|
||||
const rawSex = emp.profile?.sex
|
||||
const attendant = {
|
||||
name: emp.profile?.name || '',
|
||||
sex: rawSex === 'male' || rawSex === 'female' ? rawSex : 'none',
|
||||
mobile: emp.profile?.phone || '',
|
||||
...(emp.userId ? { id: emp.userId } : {}),
|
||||
}
|
||||
assignSubmitting.value = true
|
||||
try {
|
||||
// 后端 attendant 子文档结构:{ id: 关联登录用户ID, name, sex, mobile }
|
||||
await escortApi.update(record.value._id, { attendant })
|
||||
notify.success('陪诊师已指派')
|
||||
await escortApi.assign(record.value._id, assignTarget.value._id)
|
||||
notify.success('陪诊师已分配')
|
||||
assignVisible.value = false
|
||||
await load()
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user