fetch(modify):修复API的URL
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m1s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m1s
This commit is contained in:
@@ -165,9 +165,9 @@
|
||||
import type { FormRules } from 'element-plus'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import { PlatformAccountService, RoleService } from '@/api/modules'
|
||||
import { AccountService, RoleService } from '@/api/modules'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { PlatformRole, PlatformAccountResponse } from '@/types/api'
|
||||
import type { PlatformRole, PlatformAccount } from '@/types/api'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { CommonStatus, getStatusText, STATUS_SELECT_OPTIONS } from '@/config/constants'
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
})
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<PlatformAccountResponse[]>([])
|
||||
const tableData = ref<PlatformAccount[]>([])
|
||||
|
||||
// 表格实例引用
|
||||
const tableRef = ref()
|
||||
@@ -268,7 +268,7 @@
|
||||
]
|
||||
|
||||
// 显示对话框
|
||||
const showDialog = (type: string, row?: PlatformAccountResponse) => {
|
||||
const showDialog = (type: string, row?: PlatformAccount) => {
|
||||
dialogVisible.value = true
|
||||
dialogType.value = type
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
formData.user_type = row.user_type
|
||||
formData.enterprise_id = row.enterprise_id || null
|
||||
formData.shop_id = row.shop_id || null
|
||||
formData.status = row.status
|
||||
formData.status = row.status as CommonStatus
|
||||
formData.password = ''
|
||||
} else {
|
||||
formData.id = 0
|
||||
@@ -299,7 +299,7 @@
|
||||
}
|
||||
|
||||
// 删除账号
|
||||
const deleteAccount = (row: PlatformAccountResponse) => {
|
||||
const deleteAccount = (row: PlatformAccount) => {
|
||||
ElMessageBox.confirm(`确定要删除平台账号 ${row.username} 吗?`, '删除平台账号', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
@@ -307,7 +307,7 @@
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
await PlatformAccountService.deletePlatformAccount(row.ID)
|
||||
await AccountService.deleteAccount(row.ID)
|
||||
ElMessage.success('删除成功')
|
||||
getAccountList()
|
||||
} catch (error) {
|
||||
@@ -320,7 +320,7 @@
|
||||
}
|
||||
|
||||
// 显示修改密码对话框
|
||||
const showPasswordDialog = (row: PlatformAccountResponse) => {
|
||||
const showPasswordDialog = (row: PlatformAccount) => {
|
||||
currentAccountId.value = row.ID
|
||||
passwordForm.new_password = ''
|
||||
passwordDialogVisible.value = true
|
||||
@@ -346,7 +346,7 @@
|
||||
{
|
||||
prop: 'user_type',
|
||||
label: '账号类型',
|
||||
formatter: (row: PlatformAccountResponse) => {
|
||||
formatter: (row: PlatformAccount) => {
|
||||
const typeMap: Record<number, string> = {
|
||||
1: '超级管理员',
|
||||
2: '平台用户',
|
||||
@@ -359,7 +359,7 @@
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
formatter: (row: PlatformAccountResponse) => {
|
||||
formatter: (row: PlatformAccount) => {
|
||||
return h(ElSwitch, {
|
||||
modelValue: row.status,
|
||||
activeValue: CommonStatus.ENABLED,
|
||||
@@ -375,14 +375,14 @@
|
||||
{
|
||||
prop: 'CreatedAt',
|
||||
label: '创建时间',
|
||||
formatter: (row: PlatformAccountResponse) => formatDateTime(row.CreatedAt)
|
||||
formatter: (row: PlatformAccount) => formatDateTime(row.CreatedAt)
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
formatter: (row: PlatformAccountResponse) => {
|
||||
formatter: (row: PlatformAccount) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(ArtButtonTable, {
|
||||
icon: '',
|
||||
@@ -444,7 +444,7 @@
|
||||
}
|
||||
|
||||
// 显示分配角色对话框
|
||||
const showRoleDialog = async (row: PlatformAccountResponse) => {
|
||||
const showRoleDialog = async (row: PlatformAccount) => {
|
||||
currentAccountId.value = row.ID
|
||||
selectedRoles.value = []
|
||||
|
||||
@@ -453,7 +453,7 @@
|
||||
await loadAllRoles()
|
||||
|
||||
// 先加载当前账号的角色,再打开对话框
|
||||
const res = await PlatformAccountService.getPlatformAccountRoles(row.ID)
|
||||
const res = await AccountService.getAccountRoles(row.ID)
|
||||
if (res.code === 0) {
|
||||
// 提取角色ID数组
|
||||
const roles = res.data || []
|
||||
@@ -470,9 +470,7 @@
|
||||
const handleAssignRoles = async () => {
|
||||
roleSubmitLoading.value = true
|
||||
try {
|
||||
await PlatformAccountService.assignRolesToPlatformAccount(currentAccountId.value, {
|
||||
role_ids: selectedRoles.value
|
||||
})
|
||||
await AccountService.assignRolesToAccount(currentAccountId.value, selectedRoles.value)
|
||||
ElMessage.success('分配角色成功')
|
||||
roleDialogVisible.value = false
|
||||
// 刷新列表以更新角色显示
|
||||
@@ -492,9 +490,10 @@
|
||||
if (valid) {
|
||||
passwordSubmitLoading.value = true
|
||||
try {
|
||||
await PlatformAccountService.changePlatformAccountPassword(currentAccountId.value, {
|
||||
new_password: passwordForm.new_password
|
||||
})
|
||||
await AccountService.updateAccountPassword(
|
||||
currentAccountId.value,
|
||||
passwordForm.new_password
|
||||
)
|
||||
ElMessage.success('修改密码成功')
|
||||
passwordDialogVisible.value = false
|
||||
} catch (error) {
|
||||
@@ -512,12 +511,13 @@
|
||||
try {
|
||||
const params = {
|
||||
page: pagination.currentPage,
|
||||
page_size: pagination.pageSize,
|
||||
pageSize: pagination.pageSize,
|
||||
user_type: 2, // 筛选平台账号
|
||||
username: searchForm.username || undefined,
|
||||
phone: searchForm.phone || undefined,
|
||||
status: searchForm.status
|
||||
}
|
||||
const res = await PlatformAccountService.getPlatformAccounts(params)
|
||||
const res = await AccountService.getAccounts(params)
|
||||
if (res.code === 0) {
|
||||
tableData.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
@@ -611,16 +611,15 @@
|
||||
data.enterprise_id = formData.enterprise_id
|
||||
}
|
||||
|
||||
await PlatformAccountService.createPlatformAccount(data)
|
||||
await AccountService.createAccount(data)
|
||||
ElMessage.success('新增成功')
|
||||
} else {
|
||||
const data: any = {
|
||||
username: formData.username,
|
||||
phone: formData.phone,
|
||||
status: formData.status
|
||||
phone: formData.phone
|
||||
}
|
||||
|
||||
await PlatformAccountService.updatePlatformAccount(formData.id, data)
|
||||
await AccountService.updateAccount(formData.id, data)
|
||||
ElMessage.success('更新成功')
|
||||
}
|
||||
|
||||
@@ -652,7 +651,7 @@
|
||||
// 先更新UI
|
||||
row.status = newStatus
|
||||
try {
|
||||
await PlatformAccountService.updatePlatformAccount(row.ID, { status: newStatus })
|
||||
await AccountService.updateAccountStatus(row.ID, newStatus as 0 | 1)
|
||||
ElMessage.success('状态切换成功')
|
||||
} catch (error) {
|
||||
// 切换失败,恢复原状态
|
||||
|
||||
@@ -126,9 +126,9 @@
|
||||
import type { FormRules } from 'element-plus'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import { ShopAccountService, ShopService } from '@/api/modules'
|
||||
import { AccountService, ShopService } from '@/api/modules'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { ShopAccountResponse, ShopResponse } from '@/types/api'
|
||||
import type { PlatformAccount, ShopResponse } from '@/types/api'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { CommonStatus, getStatusText, STATUS_SELECT_OPTIONS } from '@/config/constants'
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
})
|
||||
|
||||
// 表格数据
|
||||
const tableData = ref<ShopAccountResponse[]>([])
|
||||
const tableData = ref<PlatformAccount[]>([])
|
||||
|
||||
// 表格实例引用
|
||||
const tableRef = ref()
|
||||
@@ -243,14 +243,14 @@
|
||||
]
|
||||
|
||||
// 显示对话框
|
||||
const showDialog = (type: string, row?: ShopAccountResponse) => {
|
||||
const showDialog = (type: string, row?: PlatformAccount) => {
|
||||
dialogType.value = type
|
||||
|
||||
if (type === 'edit' && row) {
|
||||
formData.id = row.id
|
||||
formData.id = row.ID
|
||||
formData.username = row.username
|
||||
formData.phone = row.phone
|
||||
formData.shop_id = row.shop_id
|
||||
formData.shop_id = row.shop_id || 0
|
||||
formData.password = ''
|
||||
} else {
|
||||
formData.id = 0
|
||||
@@ -269,8 +269,8 @@
|
||||
}
|
||||
|
||||
// 显示修改密码对话框
|
||||
const showPasswordDialog = (row: ShopAccountResponse) => {
|
||||
currentAccountId.value = row.id
|
||||
const showPasswordDialog = (row: PlatformAccount) => {
|
||||
currentAccountId.value = row.ID
|
||||
passwordForm.new_password = ''
|
||||
|
||||
// 重置表单验证状态
|
||||
@@ -282,12 +282,12 @@
|
||||
}
|
||||
|
||||
// 状态切换处理
|
||||
const handleStatusChange = async (row: ShopAccountResponse, newStatus: number) => {
|
||||
const handleStatusChange = async (row: PlatformAccount, newStatus: number) => {
|
||||
const oldStatus = row.status
|
||||
// 先更新UI
|
||||
row.status = newStatus
|
||||
try {
|
||||
await ShopAccountService.updateShopAccountStatus(row.id, { status: newStatus })
|
||||
await AccountService.updateAccountStatus(row.ID, newStatus as 0 | 1)
|
||||
ElMessage.success('状态切换成功')
|
||||
} catch (error) {
|
||||
// 切换失败,恢复原状态
|
||||
@@ -318,7 +318,7 @@
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
formatter: (row: ShopAccountResponse) => {
|
||||
formatter: (row: PlatformAccount) => {
|
||||
return h(ElSwitch, {
|
||||
modelValue: row.status,
|
||||
activeValue: CommonStatus.ENABLED,
|
||||
@@ -334,14 +334,14 @@
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '创建时间',
|
||||
formatter: (row: ShopAccountResponse) => formatDateTime(row.created_at)
|
||||
formatter: (row: PlatformAccount) => formatDateTime(row.CreatedAt)
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
formatter: (row: ShopAccountResponse) => {
|
||||
formatter: (row: PlatformAccount) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(ArtButtonTable, {
|
||||
icon: '',
|
||||
@@ -447,9 +447,10 @@
|
||||
if (valid) {
|
||||
passwordSubmitLoading.value = true
|
||||
try {
|
||||
await ShopAccountService.updateShopAccountPassword(currentAccountId.value, {
|
||||
new_password: passwordForm.new_password
|
||||
})
|
||||
await AccountService.updateAccountPassword(
|
||||
currentAccountId.value,
|
||||
passwordForm.new_password
|
||||
)
|
||||
ElMessage.success('重置密码成功')
|
||||
passwordDialogVisible.value = false
|
||||
} catch (error) {
|
||||
@@ -467,13 +468,14 @@
|
||||
try {
|
||||
const params = {
|
||||
page: pagination.currentPage,
|
||||
page_size: pagination.pageSize,
|
||||
pageSize: pagination.pageSize,
|
||||
user_type: 3, // 筛选代理账号
|
||||
username: searchForm.username || undefined,
|
||||
phone: searchForm.phone || undefined,
|
||||
shop_id: searchForm.shop_id,
|
||||
status: searchForm.status
|
||||
}
|
||||
const res = await ShopAccountService.getShopAccounts(params)
|
||||
const res = await AccountService.getAccounts(params)
|
||||
if (res.code === 0) {
|
||||
tableData.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
@@ -536,17 +538,18 @@
|
||||
username: formData.username,
|
||||
password: formData.password,
|
||||
phone: formData.phone,
|
||||
user_type: 3, // 代理账号
|
||||
shop_id: formData.shop_id
|
||||
}
|
||||
|
||||
await ShopAccountService.createShopAccount(data)
|
||||
await AccountService.createAccount(data)
|
||||
ElMessage.success('新增成功')
|
||||
} else {
|
||||
const data = {
|
||||
username: formData.username
|
||||
}
|
||||
|
||||
await ShopAccountService.updateShopAccount(formData.id, data)
|
||||
await AccountService.updateAccount(formData.id, data)
|
||||
ElMessage.success('更新成功')
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,12 @@
|
||||
<ElFormItem label="排序序号" prop="sort">
|
||||
<ElInputNumber v-model="form.sort" :min="0" :max="9999" style="width: 100%" />
|
||||
</ElFormItem>
|
||||
<ElFormItem label="状态" prop="status">
|
||||
<ElRadioGroup v-model="form.status">
|
||||
<ElRadio :value="1">启用</ElRadio>
|
||||
<ElRadio :value="0">禁用</ElRadio>
|
||||
</ElRadioGroup>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@@ -110,6 +116,8 @@
|
||||
ElMessage,
|
||||
ElMessageBox,
|
||||
ElTag,
|
||||
ElRadio,
|
||||
ElRadioGroup,
|
||||
type FormInstance,
|
||||
type FormRules
|
||||
} from 'element-plus'
|
||||
@@ -123,7 +131,9 @@
|
||||
PERMISSION_TYPE_OPTIONS,
|
||||
PERMISSION_TYPE_SELECT_OPTIONS,
|
||||
getPermissionTypeText,
|
||||
getPermissionTypeTag
|
||||
getPermissionTypeTag,
|
||||
CommonStatus,
|
||||
getStatusText
|
||||
} from '@/config/constants'
|
||||
|
||||
defineOptions({ name: 'Permission' })
|
||||
@@ -177,6 +187,7 @@
|
||||
{ label: '权限类型', prop: 'perm_type' },
|
||||
{ label: '菜单路径', prop: 'url' },
|
||||
{ label: '适用端口', prop: 'platform' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '排序', prop: 'sort' },
|
||||
{ label: '操作', prop: 'operation' }
|
||||
]
|
||||
@@ -195,14 +206,15 @@
|
||||
|
||||
// 表单引用和数据
|
||||
const formRef = ref<FormInstance>()
|
||||
const form = reactive<CreatePermissionParams>({
|
||||
const form = reactive<CreatePermissionParams & { status?: number }>({
|
||||
perm_name: '',
|
||||
perm_code: '',
|
||||
perm_type: PermissionType.MENU,
|
||||
parent_id: undefined,
|
||||
url: '',
|
||||
platform: 'all',
|
||||
sort: 0
|
||||
sort: 0,
|
||||
status: CommonStatus.ENABLED
|
||||
})
|
||||
|
||||
// 表单验证规则
|
||||
@@ -261,6 +273,21 @@
|
||||
return platformMap[row.platform || 'all'] || row.platform
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
width: 80,
|
||||
formatter: (row: PermissionTreeNode) => {
|
||||
const status = row.status ?? CommonStatus.ENABLED
|
||||
return h(
|
||||
ElTag,
|
||||
{
|
||||
type: status === CommonStatus.ENABLED ? 'success' : 'info'
|
||||
},
|
||||
() => getStatusText(status)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'sort',
|
||||
label: '排序',
|
||||
@@ -396,7 +423,8 @@
|
||||
parent_id: undefined, // 树结构中没有parent_id,需要从API获取
|
||||
url: row.url || '',
|
||||
platform: row.platform || 'all',
|
||||
sort: row.sort || 0
|
||||
sort: row.sort || 0,
|
||||
status: row.status ?? CommonStatus.ENABLED
|
||||
})
|
||||
} else {
|
||||
currentPermissionId.value = 0
|
||||
@@ -469,7 +497,8 @@
|
||||
parent_id: undefined,
|
||||
url: '',
|
||||
platform: 'all',
|
||||
sort: 0
|
||||
sort: 0,
|
||||
status: CommonStatus.ENABLED
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,12 @@
|
||||
>
|
||||
{{ data.perm_type === 1 ? '菜单' : '按钮' }}
|
||||
</ElTag>
|
||||
<ElTag
|
||||
:type="data.status === 1 ? 'success' : 'info'"
|
||||
size="small"
|
||||
>
|
||||
{{ data.status === 1 ? '启用' : '禁用' }}
|
||||
</ElTag>
|
||||
</span>
|
||||
</template>
|
||||
</ElTree>
|
||||
@@ -183,6 +189,12 @@
|
||||
>
|
||||
{{ data.perm_type === 1 ? '菜单' : '按钮' }}
|
||||
</ElTag>
|
||||
<ElTag
|
||||
:type="data.status === 1 ? 'success' : 'info'"
|
||||
size="small"
|
||||
>
|
||||
{{ data.status === 1 ? '启用' : '禁用' }}
|
||||
</ElTag>
|
||||
</span>
|
||||
<ElButton
|
||||
type="danger"
|
||||
@@ -352,6 +364,7 @@
|
||||
activeText: getStatusText(CommonStatus.ENABLED),
|
||||
inactiveText: getStatusText(CommonStatus.DISABLED),
|
||||
inlinePrompt: true,
|
||||
disabled: !hasAuth('role:update_status'),
|
||||
'onUpdate:modelValue': (val: string | number | boolean) =>
|
||||
handleStatusChange(row, val as number)
|
||||
})
|
||||
@@ -431,6 +444,7 @@
|
||||
id: node.id,
|
||||
label: node.perm_name,
|
||||
perm_type: node.perm_type,
|
||||
status: node.status ?? 1,
|
||||
children: node.children && node.children.length > 0 ? buildTreeData(node.children) : undefined
|
||||
}))
|
||||
}
|
||||
@@ -471,11 +485,13 @@
|
||||
}
|
||||
|
||||
// 根据权限ID列表设置树节点的禁用状态
|
||||
// 同时禁用状态为禁用(status=0)的权限
|
||||
const setTreeNodesDisabled = (treeNodes: any[], idsToDisable: number[]): any[] => {
|
||||
return treeNodes.map((node) => {
|
||||
const newNode = {
|
||||
...node,
|
||||
disabled: idsToDisable.includes(node.id)
|
||||
// 如果已分配或状态为禁用,则禁用该节点
|
||||
disabled: idsToDisable.includes(node.id) || node.status === 0
|
||||
}
|
||||
|
||||
if (node.children && node.children.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user