fetch(modify):账号列表合并
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m31s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m31s
This commit is contained in:
@@ -828,24 +828,24 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'platform-account',
|
||||
name: 'PlatformAccount',
|
||||
component: RoutesAlias.PlatformAccount,
|
||||
meta: {
|
||||
title: 'menus.accountManagement.platformAccount',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'shop-account',
|
||||
name: 'ShopAccount',
|
||||
component: RoutesAlias.ShopAccount,
|
||||
meta: {
|
||||
title: 'menus.accountManagement.shopAccount',
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
// {
|
||||
// path: 'platform-account',
|
||||
// name: 'PlatformAccount',
|
||||
// component: RoutesAlias.PlatformAccount,
|
||||
// meta: {
|
||||
// title: 'menus.accountManagement.platformAccount',
|
||||
// keepAlive: true
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// path: 'shop-account',
|
||||
// name: 'ShopAccount',
|
||||
// component: RoutesAlias.ShopAccount,
|
||||
// meta: {
|
||||
// title: 'menus.accountManagement.shopAccount',
|
||||
// keepAlive: true
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// path: 'customer-role',
|
||||
// name: 'CustomerRole',
|
||||
|
||||
@@ -80,7 +80,7 @@ export enum RoutesAlias {
|
||||
|
||||
// 账号管理
|
||||
Account = '/account-management/account', // 账号管理
|
||||
PlatformAccount = '/account-management/platform-account', // 平台账号管理
|
||||
// PlatformAccount = '/account-management/platform-account', // 平台账号管理
|
||||
CustomerManagement = '/account-management/customer', // 客户管理
|
||||
CustomerRole = '/account-management/customer-role', // 客户角色
|
||||
AgentManagement = '/account-management/agent', // 代理商管理
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<ElFormItem label="手机号" prop="phone">
|
||||
<ElInput v-model="formData.phone" placeholder="请输入手机号" maxlength="11" />
|
||||
</ElFormItem>
|
||||
<ElFormItem label="账号类型" prop="user_type">
|
||||
<ElFormItem v-if="dialogType === 'add'" label="账号类型" prop="user_type">
|
||||
<ElSelect
|
||||
v-model="formData.user_type"
|
||||
placeholder="请选择账号类型"
|
||||
@@ -72,6 +72,42 @@
|
||||
<ElOption label="企业账号" :value="4" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="dialogType === 'add' && formData.user_type === 3" label="关联店铺" prop="shop_id">
|
||||
<ElSelect
|
||||
v-model="formData.shop_id"
|
||||
placeholder="请输入店铺名称搜索"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="handleShopSearch"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:label="shop.shop_name"
|
||||
:value="shop.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="dialogType === 'add' && formData.user_type === 4" label="关联企业" prop="enterprise_id">
|
||||
<ElSelect
|
||||
v-model="formData.enterprise_id"
|
||||
placeholder="请输入企业名称搜索"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="handleEnterpriseSearch"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="enterprise in enterpriseList"
|
||||
:key="enterprise.id"
|
||||
:label="enterprise.enterprise_name"
|
||||
:value="enterprise.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@@ -378,12 +414,16 @@
|
||||
formData.username = row.username
|
||||
formData.phone = row.phone
|
||||
formData.user_type = row.user_type
|
||||
formData.shop_id = row.shop_id || null
|
||||
formData.enterprise_id = row.enterprise_id || null
|
||||
formData.password = ''
|
||||
} else {
|
||||
formData.id = ''
|
||||
formData.username = ''
|
||||
formData.phone = ''
|
||||
formData.user_type = 2
|
||||
formData.shop_id = null
|
||||
formData.enterprise_id = null
|
||||
formData.password = ''
|
||||
}
|
||||
}
|
||||
@@ -523,7 +563,9 @@
|
||||
username: '',
|
||||
password: '',
|
||||
phone: '',
|
||||
user_type: 2
|
||||
user_type: 2,
|
||||
shop_id: null as number | null,
|
||||
enterprise_id: null as number | null
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@@ -682,7 +724,31 @@
|
||||
{ len: 11, message: '手机号必须为 11 位', trigger: 'blur' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号格式', trigger: 'blur' }
|
||||
],
|
||||
user_type: [{ required: true, message: '请选择账号类型', trigger: 'change' }]
|
||||
user_type: [{ required: true, message: '请选择账号类型', trigger: 'change' }],
|
||||
shop_id: [
|
||||
{
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (formData.user_type === 3 && !value) {
|
||||
callback(new Error('代理账号必须关联店铺'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
enterprise_id: [
|
||||
{
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (formData.user_type === 4 && !value) {
|
||||
callback(new Error('企业账号必须关联企业'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 提交表单
|
||||
@@ -692,17 +758,31 @@
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
if (dialogType.value === 'add') {
|
||||
// 创建账号
|
||||
const data: any = {
|
||||
username: formData.username,
|
||||
phone: formData.phone,
|
||||
password: formData.password,
|
||||
user_type: formData.user_type
|
||||
}
|
||||
|
||||
if (dialogType.value === 'add') {
|
||||
data.password = formData.password
|
||||
// 根据账号类型添加相应的字段
|
||||
if (formData.user_type === 3) {
|
||||
data.shop_id = formData.shop_id
|
||||
} else if (formData.user_type === 4) {
|
||||
data.enterprise_id = formData.enterprise_id
|
||||
}
|
||||
|
||||
await AccountService.createAccount(data)
|
||||
ElMessage.success('添加成功')
|
||||
} else {
|
||||
// 编辑账号 - 只提交username和phone
|
||||
const data: any = {
|
||||
username: formData.username,
|
||||
phone: formData.phone
|
||||
}
|
||||
|
||||
await AccountService.updateAccount(Number(formData.id), data)
|
||||
ElMessage.success('更新成功')
|
||||
}
|
||||
|
||||
@@ -79,21 +79,41 @@
|
||||
<ElOption label="企业账号" :value="4" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="formData.user_type === 3" label="关联店铺ID" prop="shop_id">
|
||||
<ElInputNumber
|
||||
<ElFormItem v-if="formData.user_type === 3" label="关联店铺" prop="shop_id">
|
||||
<ElSelect
|
||||
v-model="formData.shop_id"
|
||||
:min="1"
|
||||
placeholder="请输入店铺ID"
|
||||
placeholder="请输入店铺名称搜索"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="handleShopSearch"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:label="shop.shop_name"
|
||||
:value="shop.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="formData.user_type === 4" label="关联企业ID" prop="enterprise_id">
|
||||
<ElInputNumber
|
||||
<ElFormItem v-if="formData.user_type === 4" label="关联企业" prop="enterprise_id">
|
||||
<ElSelect
|
||||
v-model="formData.enterprise_id"
|
||||
:min="1"
|
||||
placeholder="请输入企业ID"
|
||||
placeholder="请输入企业名称搜索"
|
||||
style="width: 100%"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="handleEnterpriseSearch"
|
||||
clearable
|
||||
>
|
||||
<ElOption
|
||||
v-for="enterprise in enterpriseList"
|
||||
:key="enterprise.id"
|
||||
:label="enterprise.enterprise_name"
|
||||
:value="enterprise.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="dialogType === 'edit'" label="状态">
|
||||
<ElSwitch
|
||||
@@ -255,7 +275,7 @@
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import { AccountService, RoleService, ShopService } from '@/api/modules'
|
||||
import { AccountService, RoleService, ShopService, EnterpriseService } from '@/api/modules'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { PlatformRole, PlatformAccount } from '@/types/api'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
@@ -607,6 +627,7 @@
|
||||
getAccountList()
|
||||
loadAllRoles()
|
||||
loadShopList()
|
||||
loadEnterpriseList()
|
||||
})
|
||||
|
||||
// 加载所有角色列表
|
||||
@@ -884,12 +905,13 @@
|
||||
}
|
||||
|
||||
// 加载店铺列表
|
||||
const loadShopList = async () => {
|
||||
const loadShopList = async (keyword: string = '') => {
|
||||
try {
|
||||
const res = await ShopService.getShops({
|
||||
page: 1,
|
||||
page_size: 9999,
|
||||
status: 1 // 只加载启用的店铺
|
||||
page_size: 20, // 默认加载20条
|
||||
status: 1, // 只加载启用的店铺
|
||||
shop_name: keyword || undefined // 根据店铺名称搜索
|
||||
})
|
||||
if (res.code === 0) {
|
||||
shopList.value = res.data.items || []
|
||||
@@ -898,6 +920,33 @@
|
||||
console.error('获取店铺列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 店铺搜索处理
|
||||
const handleShopSearch = (query: string) => {
|
||||
loadShopList(query)
|
||||
}
|
||||
|
||||
// 加载企业列表
|
||||
const loadEnterpriseList = async (keyword: string = '') => {
|
||||
try {
|
||||
const res = await EnterpriseService.getEnterprises({
|
||||
page: 1,
|
||||
page_size: 20, // 默认加载20条
|
||||
status: 1, // 只加载启用的企业
|
||||
enterprise_name: keyword || undefined // 根据企业名称搜索
|
||||
})
|
||||
if (res.code === 0) {
|
||||
enterpriseList.value = res.data.items || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取企业列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 企业搜索处理
|
||||
const handleEnterpriseSearch = (query: string) => {
|
||||
loadEnterpriseList(query)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user