fetch(modify):修改bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m45s

This commit is contained in:
sexygoat
2026-02-05 17:22:41 +08:00
parent d97dc5f007
commit b94c043a56
24 changed files with 2734 additions and 446 deletions

View File

@@ -24,7 +24,7 @@
<!-- 表格 -->
<ArtTable
ref="tableRef"
row-key="ID"
row-key="id"
:loading="loading"
:data="tableData"
:currentPage="pagination.currentPage"
@@ -43,9 +43,9 @@
<ElDialog
v-model="dialogVisible"
:title="dialogType === 'add' ? '添加账号' : '编辑账号'"
width="500px"
width="30%"
>
<ElForm ref="formRef" :model="formData" :rules="rules" label-width="100px">
<ElForm ref="formRef" :model="formData" :rules="rules" label-width="80px">
<ElFormItem label="账号名称" prop="username">
<ElInput v-model="formData.username" placeholder="请输入账号名称" />
</ElFormItem>
@@ -84,8 +84,8 @@
<!-- 分配角色对话框 -->
<ElDialog v-model="roleDialogVisible" title="分配角色" width="500px">
<ElCheckboxGroup v-model="selectedRoles">
<div v-for="role in allRoles" :key="role.ID" style="margin-bottom: 12px">
<ElCheckbox :label="role.ID">
<div v-for="role in allRoles" :key="role.id" style="margin-bottom: 12px">
<ElCheckbox :value="role.id">
{{ role.role_name }}
<ElTag
:type="role.role_type === 1 ? 'primary' : 'success'"
@@ -113,6 +113,7 @@
<script setup lang="ts">
import { h } from 'vue'
import { useRoute } from 'vue-router'
import { FormInstance, ElSwitch, ElCheckbox, ElCheckboxGroup, ElTag } from 'element-plus'
import { ElMessageBox, ElMessage } from 'element-plus'
import type { FormRules } from 'element-plus'
@@ -130,6 +131,7 @@
defineOptions({ name: 'Account' }) // 定义组件名称,用于 KeepAlive 缓存控制
const { hasAuth } = useAuth()
const route = useRoute()
const dialogType = ref('add')
const dialogVisible = ref(false)
@@ -272,7 +274,7 @@
}
if (type === 'edit' && row) {
formData.id = row.ID
formData.id = row.id
formData.username = row.username
formData.phone = row.phone
formData.user_type = row.user_type
@@ -295,7 +297,7 @@
})
.then(async () => {
try {
await AccountService.deleteAccount(row.ID)
await AccountService.deleteAccount(row.id)
ElMessage.success('删除成功')
getAccountList()
} catch (error) {
@@ -425,6 +427,12 @@
})
onMounted(() => {
// 从 URL 查询参数中读取 shop_id
const shopIdParam = route.query.shop_id
if (shopIdParam) {
formFilters.shop_id = Number(shopIdParam)
}
getAccountList()
loadAllRoles()
loadShopList()
@@ -444,7 +452,7 @@
// 显示分配角色对话框
const showRoleDialog = async (row: any) => {
currentAccountId.value = row.ID
currentAccountId.value = row.id
selectedRoles.value = []
try {
@@ -452,11 +460,11 @@
await loadAllRoles()
// 先加载当前账号的角色,再打开对话框
const res = await AccountService.getAccountRoles(row.ID)
const res = await AccountService.getAccountRoles(row.id)
if (res.code === 0) {
// 提取角色ID数组
const roles = res.data || []
selectedRoles.value = roles.map((role: any) => role.ID)
selectedRoles.value = roles.map((role: any) => role.id)
// 数据加载完成后再打开对话框
roleDialogVisible.value = true
}
@@ -582,7 +590,7 @@
// 先更新UI
row.status = newStatus
try {
await AccountService.updateAccountStatus(row.ID, newStatus as 0 | 1)
await AccountService.updateAccountStatus(row.id, newStatus as 0 | 1)
ElMessage.success('状态切换成功')
} catch (error) {
// 切换失败,恢复原状态

View File

@@ -168,12 +168,6 @@
</template>
</ElDialog>
<!-- 客户账号列表弹窗 -->
<CustomerAccountDialog
v-model="customerAccountDialogVisible"
:enterprise-id="currentEnterpriseId"
/>
<!-- 修改密码对话框 -->
<ElDialog v-model="passwordDialogVisible" title="修改密码" width="400px">
<ElForm ref="passwordFormRef" :model="passwordForm" :rules="passwordRules">
@@ -199,6 +193,14 @@
</div>
</template>
</ElDialog>
<!-- 企业客户操作右键菜单 -->
<ArtMenuRight
ref="enterpriseOperationMenuRef"
:menu-items="enterpriseOperationMenuItems"
:menu-width="140"
@select="handleEnterpriseOperationMenuSelect"
/>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -215,9 +217,11 @@
import { useCheckedColumns } from '@/composables/useCheckedColumns'
import { useAuth } from '@/composables/useAuth'
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
import CustomerAccountDialog from '@/components/business/CustomerAccountDialog.vue'
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
import { formatDateTime } from '@/utils/business/format'
import { BgColorEnum } from '@/enums/appEnum'
import { RoutesAlias } from '@/router/routesAlias'
defineOptions({ name: 'EnterpriseCustomer' })
@@ -227,7 +231,6 @@
const dialogVisible = ref(false)
const passwordDialogVisible = ref(false)
const customerAccountDialogVisible = ref(false)
const loading = ref(false)
const submitLoading = ref(false)
const passwordSubmitLoading = ref(false)
@@ -236,6 +239,10 @@
const currentEnterpriseId = ref<number>(0)
const shopList = ref<ShopResponse[]>([])
// 右键菜单
const enterpriseOperationMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
const currentOperatingEnterprise = ref<EnterpriseItem | null>(null)
// 搜索表单初始值
const initialSearchState = {
enterprise_name: '',
@@ -450,47 +457,30 @@
{
prop: 'operation',
label: '操作',
width: 340,
width: 200,
fixed: 'right',
formatter: (row: EnterpriseItem) => {
const buttons = []
if (hasAuth('enterprise_customer:edit')) {
buttons.push(
h(ArtButtonTable, {
text: '编辑',
iconClass: BgColorEnum.SECONDARY,
onClick: () => showDialog('edit', row)
})
)
}
if (hasAuth('enterprise_customer:look_customer')) {
buttons.push(
h(ArtButtonTable, {
text: '查看客户',
iconClass: BgColorEnum.PRIMARY,
onClick: () => viewCustomerAccounts(row)
})
)
}
if (hasAuth('enterprise_customer:card_authorization')) {
buttons.push(
h(ArtButtonTable, {
text: '卡授权',
iconClass: BgColorEnum.PRIMARY,
onClick: () => manageCards(row)
})
)
}
if (hasAuth('enterprise_customer:update_pwd')) {
// 只要有编辑、账号列表、修改密码权限之一,就显示更多操作按钮
if (
hasAuth('enterprise_customer:edit') ||
hasAuth('enterprise_customer:look_customer') ||
hasAuth('enterprise_customer:update_pwd')
) {
buttons.push(
h(ArtButtonTable, {
text: '修改密码',
iconClass: BgColorEnum.WARNING,
onClick: () => showPasswordDialog(row)
text: '更多操作',
onContextmenu: (e: MouseEvent) => showEnterpriseOperationMenu(e, row)
})
)
}
@@ -749,8 +739,11 @@
// 查看客户账号
const viewCustomerAccounts = (row: EnterpriseItem) => {
currentEnterpriseId.value = row.id
customerAccountDialogVisible.value = true
router.push({
name: 'EnterpriseCustomerAccounts',
params: { id: row.id },
query: { type: 'enterprise' }
})
}
// 卡管理
@@ -760,6 +753,59 @@
query: { id: row.id }
})
}
// 企业客户操作菜单项配置
const enterpriseOperationMenuItems = computed((): MenuItemType[] => {
const items: MenuItemType[] = []
if (hasAuth('enterprise_customer:look_customer')) {
items.push({
key: 'accountList',
label: '账号列表'
})
}
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 'accountList':
viewCustomerAccounts(currentOperatingEnterprise.value)
break
case 'edit':
showDialog('edit', currentOperatingEnterprise.value)
break
case 'updatePassword':
showPasswordDialog(currentOperatingEnterprise.value)
break
}
}
</script>
<style lang="scss" scoped>

View File

@@ -45,9 +45,9 @@
<ElDialog
v-model="dialogVisible"
:title="dialogType === 'add' ? '新增平台账号' : '编辑平台账号'"
width="500px"
width="30%"
>
<ElForm ref="formRef" :model="formData" :rules="rules" label-width="120px">
<ElForm ref="formRef" :model="formData" :rules="rules" label-width="80px">
<ElFormItem label="账号名称" prop="username">
<ElInput
v-model="formData.username"
@@ -297,14 +297,14 @@
// 列配置
const columnOptions = [
{ label: 'ID', prop: 'ID' },
{ label: 'ID', prop: 'id' },
{ label: '账号名称', prop: 'username' },
{ label: '手机号', prop: 'phone' },
{ label: '账号类型', prop: 'user_type' },
{ label: '店铺名称', prop: 'shop_name' },
{ label: '企业名称', prop: 'enterprise_name' },
{ label: '状态', prop: 'status' },
{ label: '创建时间', prop: 'CreatedAt' },
{ label: '创建时间', prop: 'created_at' },
{ label: '操作', prop: 'operation' }
]
@@ -319,7 +319,7 @@
}
if (type === 'edit' && row) {
formData.id = row.ID
formData.id = row.id
formData.username = row.username
formData.phone = row.phone
formData.user_type = row.user_type
@@ -348,7 +348,7 @@
})
.then(async () => {
try {
await AccountService.deleteAccount(row.ID)
await AccountService.deleteAccount(row.id)
ElMessage.success('删除成功')
getAccountList()
} catch (error) {
@@ -362,7 +362,7 @@
// 显示修改密码对话框
const showPasswordDialog = (row: PlatformAccount) => {
currentAccountId.value = row.ID
currentAccountId.value = row.id
passwordForm.new_password = ''
passwordDialogVisible.value = true
if (passwordFormRef.value) {
@@ -373,8 +373,8 @@
// 动态列配置
const { columnChecks, columns } = useCheckedColumns(() => [
{
prop: 'ID',
label: 'ID',
prop: 'id',
label: 'id',
width: 80
},
{
@@ -435,10 +435,10 @@
}
},
{
prop: 'CreatedAt',
prop: 'created_at',
label: '创建时间',
width: 180,
formatter: (row: PlatformAccount) => formatDateTime(row.CreatedAt)
formatter: (row: PlatformAccount) => formatDateTime(row.created_at)
},
{
prop: 'operation',
@@ -530,7 +530,7 @@
// 显示分配角色对话框
const showRoleDialog = async (row: PlatformAccount) => {
currentAccountId.value = row.ID
currentAccountId.value = row.id
selectedRoles.value = []
try {
@@ -538,11 +538,11 @@
await loadAllRoles()
// 先加载当前账号的角色,再打开对话框
const res = await AccountService.getAccountRoles(row.ID)
const res = await AccountService.getAccountRoles(row.id)
if (res.code === 0) {
// 提取角色ID数组
const roles = res.data || []
selectedRoles.value = roles.map((role: any) => role.ID)
selectedRoles.value = roles.map((role: any) => role.id)
// 数据加载完成后再打开对话框
roleDialogVisible.value = true
}
@@ -738,7 +738,7 @@
// 先更新UI
row.status = newStatus
try {
await AccountService.updateAccountStatus(row.ID, newStatus as 0 | 1)
await AccountService.updateAccountStatus(row.id, newStatus as 0 | 1)
ElMessage.success('状态切换成功')
} catch (error) {
// 切换失败,恢复原状态

View File

@@ -250,7 +250,7 @@
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 || 0
@@ -273,7 +273,7 @@
// 显示修改密码对话框
const showPasswordDialog = (row: PlatformAccount) => {
currentAccountId.value = row.ID
currentAccountId.value = row.id
passwordForm.new_password = ''
// 重置表单验证状态
@@ -290,7 +290,7 @@
// 先更新UI
row.status = newStatus
try {
await AccountService.updateAccountStatus(row.ID, newStatus as 0 | 1)
await AccountService.updateAccountStatus(row.id, newStatus as 0 | 1)
ElMessage.success('状态切换成功')
} catch (error) {
// 切换失败,恢复原状态
@@ -337,7 +337,7 @@
{
prop: 'created_at',
label: '创建时间',
formatter: (row: PlatformAccount) => formatDateTime(row.CreatedAt)
formatter: (row: PlatformAccount) => formatDateTime(row.created_at)
},
{
prop: 'operation',