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) {
// 切换失败,恢复原状态