修复bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 11m14s

This commit is contained in:
sexygoat
2026-04-08 10:19:25 +08:00
parent ff087abd44
commit b510b4539f
55 changed files with 2274 additions and 2612 deletions

View File

@@ -31,30 +31,17 @@
:pageSize="pagination.pageSize"
:total="pagination.total"
:marginTop="10"
:row-class-name="getRowClassName"
:actions="getActions"
:actionsWidth="160"
@selection-change="handleSelectionChange"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
@row-contextmenu="handleRowContextMenu"
@cell-mouse-enter="handleCellMouseEnter"
@cell-mouse-leave="handleCellMouseLeave"
>
<template #default>
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
</template>
</ArtTable>
<!-- 鼠标悬浮提示 -->
<TableContextMenuHint :visible="showContextMenuHint" :position="hintPosition" />
<!-- 右键菜单 -->
<ArtMenuRight
ref="contextMenuRef"
:menu-items="contextMenuItems"
:menu-width="120"
@select="handleContextMenuSelect"
/>
<ElDialog
v-model="dialogVisible"
:title="dialogType === 'add' ? '添加账号' : '编辑账号'"
@@ -197,10 +184,6 @@
import type { FormRules } from 'element-plus'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
import { useAuth } from '@/composables/useAuth'
import { useTableContextMenu } from '@/composables/useTableContextMenu'
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
import { AccountService } from '@/api/modules/account'
import { RoleService } from '@/api/modules/role'
import { ShopService, EnterpriseService } from '@/api/modules'
@@ -214,25 +197,13 @@
const { hasAuth } = useAuth()
const route = useRoute()
// 使用表格右键菜单功能
const {
showContextMenuHint,
hintPosition,
getRowClassName,
handleCellMouseEnter,
handleCellMouseLeave
} = useTableContextMenu()
const dialogType = ref('add')
const dialogVisible = ref(false)
const roleDialogVisible = ref(false)
const loading = ref(false)
const roleSubmitLoading = ref(false)
const currentAccountId = ref<number>(0)
const currentAccountName = ref<string>('')
const currentAccountType = ref<number>(0)
const contextMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
const currentRow = ref<any | null>(null)
const selectedRoles = ref<number[]>([])
const allRoles = ref<PlatformRole[]>([])
const rolesToAdd = ref<number[]>([])
@@ -493,6 +464,37 @@
}
])
// 操作列配置
const getActions = (row: any) => {
const actions: any[] = []
if (hasAuth('account:patch_role')) {
actions.push({
label: '分配角色',
handler: () => showRoleDialog(row),
type: 'primary'
})
}
if (hasAuth('account:edit')) {
actions.push({
label: '编辑',
handler: () => showDialog('edit', row),
type: 'primary'
})
}
if (hasAuth('account:delete')) {
actions.push({
label: '删除',
handler: () => deleteAccount(row),
type: 'danger'
})
}
return actions
}
// 表单实例
const formRef = ref<FormInstance>()
@@ -678,7 +680,12 @@
const rules = reactive<FormRules>({
username: [
{ required: true, message: '请输入账号名称', trigger: 'blur' },
{ min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
{ min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' },
{
pattern: /^[a-zA-Z0-9_-]+$/,
message: '用户名只能包含字母、数字、下划线和横线',
trigger: 'blur'
}
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
@@ -692,7 +699,7 @@
user_type: [{ required: true, message: '请选择账号类型', trigger: 'change' }],
shop_id: [
{
validator: (rule: any, value: any, callback: any) => {
validator: (_rule: any, value: any, callback: any) => {
if (formData.user_type === 3 && !value) {
callback(new Error('代理账号必须关联店铺'))
} else {
@@ -704,7 +711,7 @@
],
enterprise_id: [
{
validator: (rule: any, value: any, callback: any) => {
validator: (_rule: any, value: any, callback: any) => {
if (formData.user_type === 4 && !value) {
callback(new Error('企业账号必须关联企业'))
} else {
@@ -832,59 +839,9 @@
}
// 右键菜单项配置
const contextMenuItems = computed((): MenuItemType[] => {
const items: MenuItemType[] = []
if (hasAuth('account:patch_role')) {
items.push({ key: 'assignRole', label: '分配角色' })
}
if (hasAuth('account:edit')) {
items.push({ key: 'edit', label: '编辑' })
}
if (hasAuth('account:delete')) {
items.push({ key: 'delete', label: '删除' })
}
return items
})
// 处理表格行右键菜单
const handleRowContextMenu = (row: any, column: any, event: MouseEvent) => {
event.preventDefault()
event.stopPropagation()
currentRow.value = row
contextMenuRef.value?.show(event)
}
// 处理右键菜单选择
const handleContextMenuSelect = (item: MenuItemType) => {
if (!currentRow.value) return
switch (item.key) {
case 'assignRole':
showRoleDialog(currentRow.value)
break
case 'edit':
showDialog('edit', currentRow.value)
break
case 'delete':
deleteAccount(currentRow.value)
break
}
}
</script>
<style lang="scss" scoped>
.account-page {
// 账号管理页面样式
}
:deep(.el-table__row.table-row-with-context-menu) {
cursor: pointer;
}
.dialog-header {
display: flex;
align-items: center;

View File

@@ -35,26 +35,21 @@
:pageSize="pagination.pageSize"
:total="pagination.total"
:marginTop="10"
:row-class-name="getRowClassName"
:actions="getActions"
:actionsWidth="160"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
@row-contextmenu="handleRowContextMenu"
@cell-mouse-enter="handleCellMouseEnter"
@cell-mouse-leave="handleCellMouseLeave"
>
<template #default>
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
</template>
</ArtTable>
<!-- 鼠标悬浮提示 -->
<TableContextMenuHint :visible="showContextMenuHint" :position="hintPosition" />
<!-- 新增/编辑对话框 -->
<ElDialog
v-model="dialogVisible"
:title="dialogType === 'add' ? '新增企业客户' : '编辑企业客户'"
width="600px"
width="40%"
>
<ElForm ref="formRef" :model="form" :rules="rules" label-width="100px">
<ElFormItem label="企业编号" prop="enterprise_code">
@@ -204,14 +199,6 @@
</div>
</template>
</ElDialog>
<!-- 企业客户操作右键菜单 -->
<ArtMenuRight
ref="enterpriseOperationMenuRef"
:menu-items="enterpriseOperationMenuItems"
:menu-width="140"
@select="handleEnterpriseOperationMenuSelect"
/>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -228,12 +215,7 @@
import { useCheckedColumns } from '@/composables/useCheckedColumns'
import { useAuth } from '@/composables/useAuth'
import { useUserStore } from '@/store/modules/user'
import { useTableContextMenu } from '@/composables/useTableContextMenu'
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
import CodeGeneratorButton from '@/components/business/CodeGeneratorButton.vue'
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
import { formatDateTime } from '@/utils/business/format'
import { regionData } from '@/utils/constants/regionData'
@@ -244,15 +226,6 @@
const router = useRouter()
// 使用表格右键菜单功能
const {
showContextMenuHint,
hintPosition,
getRowClassName,
handleCellMouseEnter,
handleCellMouseLeave
} = useTableContextMenu()
// 判断是否是代理账号 (user_type === 3)
const isAgentAccount = computed(() => userStore.info.user_type === 3)
@@ -266,10 +239,6 @@
const currentEnterpriseId = ref<number>(0)
const shopTreeData = ref<ShopResponse[]>([])
// 右键菜单
const enterpriseOperationMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
const currentOperatingEnterprise = ref<EnterpriseItem | null>(null)
// 搜索表单初始值
const initialSearchState = {
enterprise_name: '',
@@ -414,7 +383,7 @@
{
prop: 'enterprise_code',
label: '企业编号',
minWidth: 150,
minWidth: 200,
showOverflowTooltip: true
},
{
@@ -482,47 +451,56 @@
label: '创建时间',
width: 180,
formatter: (row: EnterpriseItem) => formatDateTime(row.created_at)
},
{
prop: 'operation',
label: '操作',
width: 280,
fixed: 'right',
formatter: (row: EnterpriseItem) => {
const buttons = []
if (hasAuth('enterprise_customer:look_customer')) {
buttons.push(
h(ArtButtonTable, {
text: '账号列表',
onClick: () => viewCustomerAccounts(row)
})
)
}
if (hasAuth('enterprise_customer:card_authorization')) {
buttons.push(
h(ArtButtonTable, {
text: '卡授权',
onClick: () => manageCards(row)
})
)
}
if (hasAuth('enterprise_customer:device_authorization')) {
buttons.push(
h(ArtButtonTable, {
text: '设备授权',
onClick: () => manageDevices(row)
})
)
}
return h('div', { style: 'display: flex; gap: 8px;' }, buttons)
}
}
])
// 操作列配置
const getActions = (row: EnterpriseItem) => {
const actions: any[] = []
if (hasAuth('enterprise_customer:look_customer')) {
actions.push({
label: '账号列表',
handler: () => viewCustomerAccounts(row),
type: 'primary'
})
}
if (hasAuth('enterprise_customer:card_authorization')) {
actions.push({
label: '卡授权',
handler: () => manageCards(row),
type: 'primary'
})
}
if (hasAuth('enterprise_customer:device_authorization')) {
actions.push({
label: '设备授权',
handler: () => manageDevices(row),
type: 'primary'
})
}
if (hasAuth('enterprise_customer:edit')) {
actions.push({
label: '编辑',
handler: () => showDialog('edit', row),
type: 'primary'
})
}
if (hasAuth('enterprise_customer:update_pwd')) {
actions.push({
label: '修改密码',
handler: () => showPasswordDialog(row),
type: 'primary'
})
}
return actions
}
onMounted(() => {
getTableData()
// 只有非代理账号才需要加载店铺列表
@@ -840,59 +818,6 @@
}
// 企业客户操作菜单项配置
const enterpriseOperationMenuItems = computed((): MenuItemType[] => {
const items: MenuItemType[] = []
if (hasAuth('enterprise_customer:edit')) {
items.push({
key: 'edit',
label: '编辑'
})
}
if (hasAuth('enterprise_customer:update_pwd')) {
items.push({
key: 'updatePassword',
label: '修改密码'
})
}
return items
})
// 显示企业客户操作右键菜单
const showEnterpriseOperationMenu = (e: MouseEvent, row: EnterpriseItem) => {
e.preventDefault()
e.stopPropagation()
currentOperatingEnterprise.value = row
enterpriseOperationMenuRef.value?.show(e)
}
// 处理企业客户操作菜单选择
const handleEnterpriseOperationMenuSelect = (item: MenuItemType) => {
if (!currentOperatingEnterprise.value) return
switch (item.key) {
case 'edit':
showDialog('edit', currentOperatingEnterprise.value)
break
case 'updatePassword':
showPasswordDialog(currentOperatingEnterprise.value)
break
}
}
// 处理表格行右键菜单
const handleRowContextMenu = (row: EnterpriseItem, column: any, event: MouseEvent) => {
// 如果用户有编辑或修改密码权限,显示右键菜单
if (hasAuth('enterprise_customer:edit') || hasAuth('enterprise_customer:update_pwd')) {
showEnterpriseOperationMenu(event, row)
}
}
</script>
<style scoped lang="scss">
:deep(.el-table__row.table-row-with-context-menu) {
cursor: pointer;
}
</style>
<style scoped lang="scss"></style>