fix: some

This commit is contained in:
luo
2026-09-17 12:16:20 +08:00
parent 2308d82d0f
commit 76d4e4ec02
126 changed files with 11671 additions and 294 deletions

View File

@@ -20,6 +20,19 @@
>
<template #left>
<ElButton @click="showDialog('add')" v-permission="'shop:add'">新增店铺</ElButton>
<ElButton
type="primary"
v-permission="SHOP_BUSINESS_OWNER_PERMISSIONS.batch"
@click="openBatchTransferDialog"
>
批量交接
</ElButton>
<ElButton
v-permission="SHOP_BUSINESS_OWNER_PERMISSIONS.importPage"
@click="goToImportPage"
>
导入业务员
</ElButton>
</template>
</ArtTableHeader>
@@ -40,6 +53,7 @@
@current-change="handleCurrentChange"
>
<template #default>
<ElTableColumn v-if="canBatchTransfer" type="selection" width="55" />
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
</template>
</ArtTable>
@@ -310,6 +324,60 @@
:shop="currentCreditShop"
@submitted="getShopList"
/>
<!-- 批量交接平台业务员弹窗 -->
<ElDialog
v-model="batchTransferDialogVisible"
title="批量交接平台业务员"
width="560px"
destroy-on-close
>
<ElAlert type="info" :closable="false" show-icon class="batch-transfer-alert">
已选择 {{ selectedRows.length }} 家店铺(单次最多 500 家)
</ElAlert>
<ElForm label-width="110px" class="batch-transfer-form">
<ElFormItem label="交接方式">
<ElRadioGroup v-model="batchTransferMode">
<ElRadio label="rebind">换绑业务员</ElRadio>
<ElRadio label="clear">清空负责人</ElRadio>
</ElRadioGroup>
</ElFormItem>
<ElFormItem v-if="batchTransferMode === 'rebind'" label="目标业务员">
<ElSelect
v-model="batchTransferAccountId"
filterable
remote
clearable
:loading="batchOwnerLoading"
:remote-method="searchBatchOwners"
placeholder="请选择或搜索平台业务员"
style="width: 100%"
>
<ElOption
v-for="owner in batchOwnerOptions"
:key="owner.id"
:label="owner.username"
:value="owner.id"
>
<div style="display: flex; justify-content: space-between">
<span>{{ owner.username }}</span>
<span style="font-size: 12px; color: var(--el-text-color-secondary)">
{{ owner.phone_summary }}
</span>
</div>
</ElOption>
</ElSelect>
</ElFormItem>
</ElForm>
<template #footer>
<div class="dialog-footer">
<ElButton @click="batchTransferDialogVisible = false">取消</ElButton>
<ElButton type="primary" :loading="batchSubmitting" @click="handleBatchTransfer">
确认交接
</ElButton>
</div>
</template>
</ElDialog>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -334,10 +402,17 @@
import { useAuth } from '@/composables/useAuth'
import { useUserStore } from '@/store/modules/user'
import { generateShopCode } from '@/utils/codeGenerator'
import { CommissionService, ShopService, RoleService } from '@/api/modules'
import {
BusinessUserGroupService,
CommissionService,
RoleService,
ShopService
} from '@/api/modules'
import ShopCreditLimitDialog from '@/components/business/ShopCreditLimitDialog.vue'
import type { SearchFormItem } from '@/types'
import type {
BatchUpdateBusinessOwnerParams,
BusinessUserGroupItem,
CreateShopParams,
ShopBusinessOwnerCandidate,
ShopResponse,
@@ -348,7 +423,14 @@
import { RoleType, RoleStatus } from '@/types/api'
import { formatDateTime } from '@/utils/business/format'
import { getCompatibleNumericId } from '@/utils/business/id'
import { CommonStatus, getStatusText, STATUS_SELECT_OPTIONS } from '@/config/constants'
import {
BUSINESS_USER_GROUP_BUSINESS_LINE_OPTIONS,
CommonStatus,
getBusinessUserGroupBusinessLineLabel,
getStatusText,
SHOP_BUSINESS_OWNER_PERMISSIONS,
STATUS_SELECT_OPTIONS
} from '@/config/constants'
import { regionData } from '@/utils/constants/regionData'
import { RoutesAlias } from '@/router/routesAlias'
import { AUDIT_PERMISSIONS } from '@/config/constants/audit'
@@ -484,7 +566,10 @@
parent_id: undefined as number | undefined,
level: undefined as number | undefined,
status: undefined as number | undefined,
business_owner_account_id: undefined as number | undefined
business_owner_account_id: undefined as number | undefined,
business_user_group_id: undefined as number | undefined,
business_line: undefined as string | undefined,
ungrouped: undefined as number | undefined
}
// 响应式表单数据
@@ -505,6 +590,22 @@
// 选中的行数据
const selectedRows = ref<any[]>([])
// 业务用户组筛选选项(非代理账号可见)
const groupOptions = ref<BusinessUserGroupItem[]>([])
const groupLoading = ref(false)
// 批量交接平台业务员
const batchTransferDialogVisible = ref(false)
const batchTransferMode = ref<'rebind' | 'clear'>('rebind')
const batchTransferAccountId = ref<number | null>(null)
const batchOwnerOptions = ref<ShopBusinessOwnerCandidate[]>([])
const batchOwnerLoading = ref(false)
const batchSubmitting = ref(false)
const canBatchTransfer = computed(
() => !isAgentAccount.value && hasAuth(SHOP_BUSINESS_OWNER_PERMISSIONS.batch)
)
// 重置表单
const handleReset = () => {
Object.assign(searchForm, { ...initialSearchState })
@@ -602,6 +703,50 @@
label: `${salesperson.username} (${salesperson.phone_summary})`,
value: salesperson.id
}))
},
{
label: '业务用户组',
prop: 'business_user_group_id',
type: 'select' as const,
config: {
clearable: true,
filterable: true,
loading: groupLoading.value,
placeholder: '请选择业务用户组'
},
options: () =>
groupOptions.value.map((group) => ({
label: group.business_line_name
? `${group.name}${group.business_line_name}`
: group.name,
value: group.id
}))
},
{
label: '业务线',
prop: 'business_line',
type: 'select' as const,
config: {
clearable: true,
placeholder: '请选择业务线'
},
options: BUSINESS_USER_GROUP_BUSINESS_LINE_OPTIONS.map((item) => ({
label: item.label,
value: item.value
}))
},
{
label: '未分组',
prop: 'ungrouped',
type: 'select' as const,
config: {
clearable: true,
placeholder: '是=无负责人或负责人无分组'
},
options: [
{ label: '是', value: 1 },
{ label: '否', value: 0 }
]
}
]
: [])
@@ -616,6 +761,7 @@
{ label: '联系人', prop: 'contact_name' },
{ label: '联系电话', prop: 'contact_phone' },
{ label: '平台业务员', prop: 'business_owner_username' },
{ label: '业务用户组', prop: 'business_user_group_name' },
...(canModifyShopStatus ? [{ label: '状态', prop: 'status' }] : []),
{ label: '创建时间', prop: 'created_at' },
{ label: '操作', prop: 'operation' }
@@ -776,6 +922,23 @@
showOverflowTooltip: true,
formatter: (row: ShopResponse) => formatBusinessOwner(row)
},
{
prop: 'business_user_group_name',
label: '业务用户组',
minWidth: 160,
showOverflowTooltip: true,
formatter: (row: ShopResponse) => {
if (!row.business_user_group_id) return '-'
const name = row.business_user_group_name || row.business_user_group_code || '-'
const businessLine = getBusinessUserGroupBusinessLineLabel(
row.business_user_group_business_line
)
const text =
businessLine && businessLine !== '-' ? `${name}${businessLine}` : name
if (row.business_user_group_enabled) return text
return h(ElTag, { type: 'danger', size: 'small' }, { default: () => `${text}(已停用)` })
}
},
{
prop: 'client_login_disabled',
label: 'C 端登录',
@@ -1020,6 +1183,7 @@
searchParentShops('') // 加载上级店铺选项
if (!isAgentAccount.value) {
searchPlatformSalespeople('') // 加载启用的平台业务员选项
loadGroupOptions() // 加载业务用户组选项
}
})
@@ -1038,7 +1202,11 @@
level: searchForm.level,
status: searchForm.status,
...(!isAgentAccount.value && {
business_owner_account_id: searchForm.business_owner_account_id
business_owner_account_id: searchForm.business_owner_account_id,
business_user_group_id: searchForm.business_user_group_id,
business_line: searchForm.business_line || undefined,
ungrouped:
searchForm.ungrouped === undefined ? undefined : searchForm.ungrouped === 1
})
}
const res = await ShopService.getShops(params)
@@ -1062,6 +1230,89 @@
selectedRows.value = selection
}
// 打开批量交接弹窗
const openBatchTransferDialog = () => {
if (selectedRows.value.length === 0) {
ElMessage.warning('请先勾选需要交接的店铺')
return
}
if (selectedRows.value.length > 500) {
ElMessage.warning('单次最多可交接 500 家店铺')
return
}
batchTransferMode.value = 'rebind'
batchTransferAccountId.value = null
void searchBatchOwners('')
batchTransferDialogVisible.value = true
}
// 搜索批量交接目标业务员
const searchBatchOwners = async (query: string) => {
batchOwnerLoading.value = true
try {
const res = await ShopService.getBusinessOwnerCandidates({
page: 1,
page_size: 20,
keyword: query || undefined
})
if (res.code === 0) {
batchOwnerOptions.value = res.data.items || []
}
} catch (error) {
console.error('获取平台业务员列表失败:', error)
batchOwnerOptions.value = []
} finally {
batchOwnerLoading.value = false
}
}
// 提交批量交接
const handleBatchTransfer = async () => {
if (batchTransferMode.value === 'rebind' && !batchTransferAccountId.value) {
ElMessage.warning('请选择目标业务员')
return
}
batchSubmitting.value = true
try {
const data: BatchUpdateBusinessOwnerParams = {
shop_ids: Array.from(new Set(selectedRows.value.map((row: ShopResponse) => row.id))),
business_owner_account_id:
batchTransferMode.value === 'clear' ? null : batchTransferAccountId.value
}
const res = await ShopService.batchUpdateBusinessOwner(data)
if (res.code === 0) {
ElMessage.success(`批量交接成功,共处理 ${res.data?.shop_count ?? 0} 家店铺`)
batchTransferDialogVisible.value = false
selectedRows.value = []
await getShopList()
}
} catch (error) {
console.error('批量交接失败:', error)
} finally {
batchSubmitting.value = false
}
}
// 跳转到业务负责人导入页
const goToImportPage = () => {
router.push(RoutesAlias.BusinessOwnerImport)
}
// 加载业务用户组选项(非代理账号)
const loadGroupOptions = async () => {
groupLoading.value = true
try {
const res = await BusinessUserGroupService.getGroups({ page: 1, page_size: 100 })
if (res.code === 0) {
groupOptions.value = res.data.items || []
}
} catch (error) {
console.error('加载业务用户组失败:', error)
} finally {
groupLoading.value = false
}
}
// 表单验证规则
const rules = reactive<FormRules>({
shop_name: [