befly-admin 3.4.5 → 3.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitignore +2 -0
- package/bunfig.toml +1 -8
- package/index.html +2 -2
- package/package.json +12 -8
- package/src/config/index.ts +20 -0
- package/src/layouts/{internal/0.vue → default.vue} +51 -21
- package/src/main.ts +3 -5
- package/src/plugins/global.ts +17 -0
- package/src/plugins/{internal/http.ts → http.ts} +1 -1
- package/src/router/index.ts +55 -0
- package/src/styles/{internal/index.scss → global.scss} +29 -29
- package/src/types/auto-imports.d.ts +176 -637
- package/src/types/components.d.ts +28 -19
- package/src/types/typed-router.d.ts +32 -0
- package/src/utils/index.ts +21 -9
- package/src/views/index.vue +27 -0
- package/src/views/internal/login.vue +73 -0
- package/src/views/test.vue +60 -0
- package/tsconfig.json +4 -4
- package/vite.config.ts +134 -60
- package/src/components/internal/Icon.vue +0 -41
- package/src/components/internal/README.md +0 -27
- package/src/layouts/4.vue +0 -17
- package/src/layouts/internal/1.vue +0 -22
- package/src/layouts/internal/2.vue +0 -169
- package/src/layouts/internal/README.md +0 -27
- package/src/plugins/internal/README.md +0 -36
- package/src/plugins/internal/router.ts +0 -48
- package/src/plugins/internal/store.ts +0 -19
- package/src/styles/internal/README.md +0 -27
- package/src/styles/internal/mixins.scss +0 -98
- package/src/types/env.d.ts +0 -23
- package/src/utils/README.md +0 -37
- package/src/utils/internal/README.md +0 -21
- package/src/utils/internal/index.ts +0 -30
- package/src/views/internal/403/403.vue +0 -66
- package/src/views/internal/README.md +0 -27
- package/src/views/internal/admin/components/edit.vue +0 -147
- package/src/views/internal/admin/components/role.vue +0 -135
- package/src/views/internal/admin/index.vue +0 -169
- package/src/views/internal/dict/components/edit.vue +0 -156
- package/src/views/internal/dict/index.vue +0 -159
- package/src/views/internal/index/components/addonList.vue +0 -125
- package/src/views/internal/index/components/environmentInfo.vue +0 -97
- package/src/views/internal/index/components/operationLogs.vue +0 -112
- package/src/views/internal/index/components/performanceMetrics.vue +0 -148
- package/src/views/internal/index/components/quickActions.vue +0 -27
- package/src/views/internal/index/components/serviceStatus.vue +0 -193
- package/src/views/internal/index/components/systemNotifications.vue +0 -136
- package/src/views/internal/index/components/systemOverview.vue +0 -188
- package/src/views/internal/index/components/systemResources.vue +0 -104
- package/src/views/internal/index/components/userInfo.vue +0 -202
- package/src/views/internal/index/index.vue +0 -62
- package/src/views/internal/login/components/emailLoginForm.vue +0 -163
- package/src/views/internal/login/components/registerForm.vue +0 -168
- package/src/views/internal/login/components/welcomePanel.vue +0 -61
- package/src/views/internal/login/index_1.vue +0 -189
- package/src/views/internal/menu/components/edit.vue +0 -150
- package/src/views/internal/menu/index.vue +0 -168
- package/src/views/internal/news/detail/detail_2.vue +0 -26
- package/src/views/internal/news/detail/index.vue +0 -26
- package/src/views/internal/news/news.vue +0 -26
- package/src/views/internal/role/components/api.vue +0 -280
- package/src/views/internal/role/components/edit.vue +0 -129
- package/src/views/internal/role/components/menu.vue +0 -143
- package/src/views/internal/role/index.vue +0 -179
- package/src/views/internal/user/user.vue +0 -320
- /package/src/plugins/{internal/storage.ts → storage.ts} +0 -0
- /package/src/styles/{internal/variables.scss → variables.scss} +0 -0
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<tiny-dialog-box v-model:visible="$Data.visible" :title="$Prop.actionType === 'upd' ? '编辑管理员' : '添加管理员'" width="600px" :append-to-body="true" :show-footer="true" :esc-closable="false" top="10vh" @close="$Method.onClose">
|
|
3
|
-
<tiny-form :model="$Data.formData" label-width="120px" label-position="left" :rules="$Data2.formRules" :ref="(el) => ($From.form = el)">
|
|
4
|
-
<tiny-form-item label="用户名" prop="username">
|
|
5
|
-
<tiny-input v-model="$Data.formData.username" placeholder="请输入用户名" :disabled="$Prop.actionType === 'upd'" />
|
|
6
|
-
</tiny-form-item>
|
|
7
|
-
<tiny-form-item label="邮箱" prop="email">
|
|
8
|
-
<tiny-input v-model="$Data.formData.email" placeholder="请输入邮箱" />
|
|
9
|
-
</tiny-form-item>
|
|
10
|
-
<tiny-form-item v-if="$Prop.actionType === 'add'" label="密码" prop="password">
|
|
11
|
-
<tiny-input v-model="$Data.formData.password" type="password" placeholder="请输入密码,至少6位" />
|
|
12
|
-
</tiny-form-item>
|
|
13
|
-
<tiny-form-item label="姓名" prop="name">
|
|
14
|
-
<tiny-input v-model="$Data.formData.name" placeholder="请输入姓名" />
|
|
15
|
-
</tiny-form-item>
|
|
16
|
-
<tiny-form-item label="昵称" prop="nickname">
|
|
17
|
-
<tiny-input v-model="$Data.formData.nickname" placeholder="请输入昵称" />
|
|
18
|
-
</tiny-form-item>
|
|
19
|
-
<tiny-form-item label="手机号" prop="phone">
|
|
20
|
-
<tiny-input v-model="$Data.formData.phone" placeholder="请输入手机号" />
|
|
21
|
-
</tiny-form-item>
|
|
22
|
-
<tiny-form-item v-if="$Prop.actionType === 'upd'" label="状态" prop="state">
|
|
23
|
-
<tiny-radio-group v-model="$Data.formData.state">
|
|
24
|
-
<tiny-radio :label="1">正常</tiny-radio>
|
|
25
|
-
<tiny-radio :label="2">禁用</tiny-radio>
|
|
26
|
-
</tiny-radio-group>
|
|
27
|
-
</tiny-form-item>
|
|
28
|
-
</tiny-form>
|
|
29
|
-
<template #footer>
|
|
30
|
-
<tiny-button @click="$Method.onClose">取消</tiny-button>
|
|
31
|
-
<tiny-button type="primary" @click="$Method.onSubmit">确定</tiny-button>
|
|
32
|
-
</template>
|
|
33
|
-
</tiny-dialog-box>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script setup>
|
|
37
|
-
const $Prop = defineProps({
|
|
38
|
-
modelValue: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: false
|
|
41
|
-
},
|
|
42
|
-
actionType: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: 'add'
|
|
45
|
-
},
|
|
46
|
-
rowData: {
|
|
47
|
-
type: Object,
|
|
48
|
-
default: {}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const $Emit = defineEmits(['update:modelValue', 'success']);
|
|
53
|
-
|
|
54
|
-
// 表单引用
|
|
55
|
-
const $From = $shallowRef({
|
|
56
|
-
form: null
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const $Data = $ref({
|
|
60
|
-
visible: false,
|
|
61
|
-
formData: {
|
|
62
|
-
id: 0,
|
|
63
|
-
username: '',
|
|
64
|
-
email: '',
|
|
65
|
-
password: '',
|
|
66
|
-
name: '',
|
|
67
|
-
nickname: '',
|
|
68
|
-
phone: '',
|
|
69
|
-
state: 1
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const $Data2 = $shallowRef({
|
|
74
|
-
formRules: {
|
|
75
|
-
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
|
76
|
-
email: [
|
|
77
|
-
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
|
78
|
-
{ type: 'email', message: '邮箱格式不正确', trigger: 'blur' }
|
|
79
|
-
],
|
|
80
|
-
password: [
|
|
81
|
-
{ required: true, message: '请输入密码', trigger: 'blur' },
|
|
82
|
-
{ min: 6, message: '密码至少6位', trigger: 'blur' }
|
|
83
|
-
],
|
|
84
|
-
name: [{ min: 2, max: 50, message: '姓名长度在 2 到 50 个字符', trigger: 'blur' }],
|
|
85
|
-
nickname: [{ min: 2, max: 50, message: '昵称长度在 2 到 50 个字符', trigger: 'blur' }],
|
|
86
|
-
phone: [{ pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确', trigger: 'blur' }]
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// 方法集合
|
|
91
|
-
const $Method = {
|
|
92
|
-
async initData() {
|
|
93
|
-
$Method.onShow();
|
|
94
|
-
if ($Prop.actionType === 'upd' && $Prop.rowData.id) {
|
|
95
|
-
// 编辑模式:复制数据
|
|
96
|
-
$Data.formData.id = $Prop.rowData.id || 0;
|
|
97
|
-
$Data.formData.username = $Prop.rowData.username || '';
|
|
98
|
-
$Data.formData.email = $Prop.rowData.email || '';
|
|
99
|
-
$Data.formData.name = $Prop.rowData.name || '';
|
|
100
|
-
$Data.formData.nickname = $Prop.rowData.nickname || '';
|
|
101
|
-
$Data.formData.phone = $Prop.rowData.phone || '';
|
|
102
|
-
$Data.formData.state = $Prop.rowData.state ?? 1;
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
onShow() {
|
|
107
|
-
setTimeout(() => {
|
|
108
|
-
$Data.visible = $Prop.modelValue;
|
|
109
|
-
}, 100);
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
onClose() {
|
|
113
|
-
$Data.visible = false;
|
|
114
|
-
setTimeout(() => {
|
|
115
|
-
$Emit('update:modelValue', false);
|
|
116
|
-
}, 300);
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
async onSubmit() {
|
|
120
|
-
try {
|
|
121
|
-
const valid = await $From.form.validate();
|
|
122
|
-
if (!valid) return;
|
|
123
|
-
|
|
124
|
-
const res = await $Http($Prop.actionType === 'upd' ? '/addon/admin/adminUpd' : '/addon/admin/adminIns', $Data.formData);
|
|
125
|
-
|
|
126
|
-
Modal.message({
|
|
127
|
-
message: $Prop.actionType === 'upd' ? '编辑成功' : '添加成功',
|
|
128
|
-
status: 'success'
|
|
129
|
-
});
|
|
130
|
-
$Emit('success');
|
|
131
|
-
$Method.onClose();
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error('提交失败:', error);
|
|
134
|
-
Modal.message({
|
|
135
|
-
message: '提交失败',
|
|
136
|
-
status: 'error'
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
$Method.initData();
|
|
143
|
-
</script>
|
|
144
|
-
|
|
145
|
-
<style scoped lang="scss">
|
|
146
|
-
// 可根据需要添加样式
|
|
147
|
-
</style>
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<tiny-dialog-box v-model:visible="$Data.visible" title="分配角色" width="600px" :append-to-body="true" :show-footer="true" :esc-closable="false" top="20vh" @close="$Method.onClose">
|
|
3
|
-
<div class="role-dialog">
|
|
4
|
-
<div class="user-info">
|
|
5
|
-
<tiny-tag type="info">{{ $Prop.rowData.username }}</tiny-tag>
|
|
6
|
-
<span class="user-email">{{ $Prop.rowData.email }}</span>
|
|
7
|
-
</div>
|
|
8
|
-
<tiny-divider />
|
|
9
|
-
<tiny-select v-model="$Data.checkedRoleCode" :options="$Data.roleOptions" placeholder="请选择角色" />
|
|
10
|
-
</div>
|
|
11
|
-
<template #footer>
|
|
12
|
-
<tiny-button @click="$Method.onClose">取消</tiny-button>
|
|
13
|
-
<tiny-button type="primary" @click="$Method.onSubmit">确定</tiny-button>
|
|
14
|
-
</template>
|
|
15
|
-
</tiny-dialog-box>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup>
|
|
19
|
-
const $Prop = defineProps({
|
|
20
|
-
modelValue: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: false
|
|
23
|
-
},
|
|
24
|
-
rowData: {
|
|
25
|
-
type: Object,
|
|
26
|
-
default: {}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const $Emit = defineEmits(['update:modelValue', 'success']);
|
|
31
|
-
|
|
32
|
-
const $Data = $ref({
|
|
33
|
-
visible: false,
|
|
34
|
-
roleOptions: [],
|
|
35
|
-
checkedRoleCode: ''
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// 方法集合
|
|
39
|
-
const $Method = {
|
|
40
|
-
async initData() {
|
|
41
|
-
$Method.onShow();
|
|
42
|
-
await Promise.all([$Method.apiRoleList(), $Method.apiAdminRoleDetail()]);
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
onShow() {
|
|
46
|
-
setTimeout(() => {
|
|
47
|
-
$Data.visible = $Prop.modelValue;
|
|
48
|
-
}, 100);
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
onClose() {
|
|
52
|
-
$Data.visible = false;
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
$Emit('update:modelValue', false);
|
|
55
|
-
}, 300);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
// 加载角色列表
|
|
59
|
-
async apiRoleList() {
|
|
60
|
-
try {
|
|
61
|
-
const res = await $Http('/addon/admin/role/list', {
|
|
62
|
-
page: 1,
|
|
63
|
-
limit: 1000
|
|
64
|
-
});
|
|
65
|
-
const roleList = res.data.lists || [];
|
|
66
|
-
$Data.roleOptions = roleList
|
|
67
|
-
.filter((role) => role.state === 1)
|
|
68
|
-
.map((role) => ({
|
|
69
|
-
label: role.name,
|
|
70
|
-
value: role.code
|
|
71
|
-
}));
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error('加载角色列表失败:', error);
|
|
74
|
-
Modal.message({ message: '加载角色列表失败', status: 'error' });
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
// 加载管理员角色
|
|
79
|
-
async apiAdminRoleDetail() {
|
|
80
|
-
if (!$Prop.rowData.id) return;
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
const res = await $Http('/addon/admin/roleDetail', {
|
|
84
|
-
adminId: $Prop.rowData.id
|
|
85
|
-
});
|
|
86
|
-
$Data.checkedRoleCode = res.data.roleCode || '';
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error('加载用户角色失败:', error);
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
// 提交角色分配
|
|
93
|
-
async onSubmit() {
|
|
94
|
-
if (!$Data.checkedRoleCode) {
|
|
95
|
-
Modal.message({ message: '请选择角色', status: 'warning' });
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
const res = await $Http('/addon/admin/roleSave', {
|
|
101
|
-
adminId: $Prop.rowData.id,
|
|
102
|
-
roleCode: $Data.checkedRoleCode
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (res.code === 0) {
|
|
106
|
-
Modal.message({ message: '角色分配成功', status: 'success' });
|
|
107
|
-
$Method.onClose();
|
|
108
|
-
$Emit('success');
|
|
109
|
-
} else {
|
|
110
|
-
Modal.message({ message: res.msg || '分配失败', status: 'error' });
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.error('分配失败:', error);
|
|
114
|
-
Modal.message({ message: '分配失败', status: 'error' });
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
$Method.initData();
|
|
120
|
-
</script>
|
|
121
|
-
|
|
122
|
-
<style scoped lang="scss">
|
|
123
|
-
.role-dialog {
|
|
124
|
-
.user-info {
|
|
125
|
-
display: flex;
|
|
126
|
-
align-items: center;
|
|
127
|
-
gap: 12px;
|
|
128
|
-
margin-bottom: 16px;
|
|
129
|
-
|
|
130
|
-
.user-email {
|
|
131
|
-
color: $text-secondary;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
</style>
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="page-admin page-table">
|
|
3
|
-
<div class="main-tool">
|
|
4
|
-
<div class="left">
|
|
5
|
-
<tiny-button type="primary" @click="$Method.onAction('add', {})">
|
|
6
|
-
<template #icon>
|
|
7
|
-
<Icon name="Plus" :size="16" />
|
|
8
|
-
</template>
|
|
9
|
-
添加管理员
|
|
10
|
-
</tiny-button>
|
|
11
|
-
</div>
|
|
12
|
-
<div class="right">
|
|
13
|
-
<tiny-button @click="$Method.handleRefresh">
|
|
14
|
-
<template #icon>
|
|
15
|
-
<Icon name="RotateCw" :size="16" />
|
|
16
|
-
</template>
|
|
17
|
-
刷新
|
|
18
|
-
</tiny-button>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
|
|
22
|
-
<div class="main-table">
|
|
23
|
-
<tiny-grid :data="$Data.tableData" header-cell-class-name="custom-table-cell-class" size="small" height="100%" seq-serial>
|
|
24
|
-
<tiny-grid-column type="index" title="序号" :width="60" />
|
|
25
|
-
<tiny-grid-column field="username" title="用户名" />
|
|
26
|
-
<tiny-grid-column field="email" title="邮箱" :width="200" />
|
|
27
|
-
<tiny-grid-column field="nickname" title="昵称" :width="150" />
|
|
28
|
-
<tiny-grid-column field="roleCode" title="角色" :width="120" />
|
|
29
|
-
<tiny-grid-column field="state" title="状态" :width="100">
|
|
30
|
-
<template #default="{ row }">
|
|
31
|
-
<tiny-tag v-if="row.state === 1" type="success">正常</tiny-tag>
|
|
32
|
-
<tiny-tag v-else-if="row.state === 2" type="warning">禁用</tiny-tag>
|
|
33
|
-
<tiny-tag v-else type="danger">已删除</tiny-tag>
|
|
34
|
-
</template>
|
|
35
|
-
</tiny-grid-column>
|
|
36
|
-
<tiny-grid-column title="操作" :width="120" align="right">
|
|
37
|
-
<template #default="{ row }">
|
|
38
|
-
<tiny-dropdown title="操作" trigger="click" size="small" border visible-arrow @item-click="(data) => $Method.onAction(data.itemData.command, row)">
|
|
39
|
-
<template #dropdown>
|
|
40
|
-
<tiny-dropdown-menu>
|
|
41
|
-
<tiny-dropdown-item :item-data="{ command: 'role' }">
|
|
42
|
-
<Icon name="User" />
|
|
43
|
-
分配角色
|
|
44
|
-
</tiny-dropdown-item>
|
|
45
|
-
<tiny-dropdown-item :item-data="{ command: 'upd' }">
|
|
46
|
-
<Icon name="Edit" />
|
|
47
|
-
编辑
|
|
48
|
-
</tiny-dropdown-item>
|
|
49
|
-
<tiny-dropdown-item :item-data="{ command: 'del' }" divided>
|
|
50
|
-
<Icon name="Trash2" />
|
|
51
|
-
删除
|
|
52
|
-
</tiny-dropdown-item>
|
|
53
|
-
</tiny-dropdown-menu>
|
|
54
|
-
</template>
|
|
55
|
-
</tiny-dropdown>
|
|
56
|
-
</template>
|
|
57
|
-
</tiny-grid-column>
|
|
58
|
-
</tiny-grid>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<div class="main-page">
|
|
62
|
-
<tiny-pager :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.pageSize" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @size-change="$Method.handleSizeChange" />
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
<!-- 编辑对话框组件 -->
|
|
66
|
-
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.apiAdminList" />
|
|
67
|
-
|
|
68
|
-
<!-- 角色分配对话框组件 -->
|
|
69
|
-
<RoleDialog v-if="$Data.roleVisible" v-model="$Data.roleVisible" :row-data="$Data.rowData" @success="$Method.apiAdminList" />
|
|
70
|
-
</div>
|
|
71
|
-
</template>
|
|
72
|
-
|
|
73
|
-
<script setup>
|
|
74
|
-
import EditDialog from './components/edit.vue';
|
|
75
|
-
import RoleDialog from './components/role.vue';
|
|
76
|
-
|
|
77
|
-
// 响应式数据
|
|
78
|
-
const $Data = $ref({
|
|
79
|
-
tableData: [],
|
|
80
|
-
pagerConfig: {
|
|
81
|
-
currentPage: 1,
|
|
82
|
-
pageSize: 30,
|
|
83
|
-
total: 0,
|
|
84
|
-
align: 'right',
|
|
85
|
-
layout: 'total, prev, pager, next, jumper'
|
|
86
|
-
},
|
|
87
|
-
editVisible: false,
|
|
88
|
-
roleVisible: false,
|
|
89
|
-
actionType: 'add',
|
|
90
|
-
rowData: {}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// 方法
|
|
94
|
-
const $Method = {
|
|
95
|
-
async initData() {
|
|
96
|
-
await $Method.apiAdminList();
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
// 加载管理员列表
|
|
100
|
-
async apiAdminList() {
|
|
101
|
-
try {
|
|
102
|
-
const res = await $Http('/addon/admin/list', {
|
|
103
|
-
page: $Data.pagerConfig.currentPage,
|
|
104
|
-
limit: $Data.pagerConfig.pageSize
|
|
105
|
-
});
|
|
106
|
-
$Data.tableData = res.data.lists || [];
|
|
107
|
-
$Data.pagerConfig.total = res.data.total || 0;
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error('加载管理员列表失败:', error);
|
|
110
|
-
Modal.message({
|
|
111
|
-
message: '加载数据失败',
|
|
112
|
-
status: 'error'
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
// 删除管理员
|
|
118
|
-
async apiAdminDel(row) {
|
|
119
|
-
Modal.confirm({
|
|
120
|
-
header: '确认删除',
|
|
121
|
-
body: `确定要删除管理员"${row.username}" 吗?`,
|
|
122
|
-
status: 'warning'
|
|
123
|
-
}).then(async () => {
|
|
124
|
-
try {
|
|
125
|
-
const res = await $Http('/addon/admin/del', { id: row.id });
|
|
126
|
-
if (res.code === 0) {
|
|
127
|
-
Modal.message({ message: '删除成功', status: 'success' });
|
|
128
|
-
$Method.apiAdminList();
|
|
129
|
-
} else {
|
|
130
|
-
Modal.message({ message: res.msg || '删除失败', status: 'error' });
|
|
131
|
-
}
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error('删除失败:', error);
|
|
134
|
-
Modal.message({ message: '删除失败', status: 'error' });
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
// 刷新
|
|
140
|
-
handleRefresh() {
|
|
141
|
-
$Method.apiAdminList();
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
// 分页改变
|
|
145
|
-
onPageChange({ currentPage }) {
|
|
146
|
-
$Data.pagerConfig.currentPage = currentPage;
|
|
147
|
-
$Method.apiAdminList();
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
// 操作菜单点击
|
|
151
|
-
onAction(command, rowData) {
|
|
152
|
-
$Data.actionType = command;
|
|
153
|
-
$Data.rowData = rowData;
|
|
154
|
-
if (command === 'add' || command === 'upd') {
|
|
155
|
-
$Data.editVisible = true;
|
|
156
|
-
} else if (command === 'role') {
|
|
157
|
-
$Data.roleVisible = true;
|
|
158
|
-
} else if (command === 'del') {
|
|
159
|
-
$Method.apiAdminDel(rowData);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
$Method.initData();
|
|
165
|
-
</script>
|
|
166
|
-
|
|
167
|
-
<style scoped lang="scss">
|
|
168
|
-
// 样式继承自全局 page-table
|
|
169
|
-
</style>
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<tiny-dialog-box v-model:visible="$Data.visible" :title="$Prop.actionType === 'upd' ? '编辑字典' : '添加字典'" width="600px" :append-to-body="true" :show-footer="true" :esc-closable="false" top="10vh" @close="$Method.onClose">
|
|
3
|
-
<tiny-form :model="$Data.formData" label-width="120px" label-position="left" :rules="$Data2.formRules" :ref="(el) => ($From.form = el)">
|
|
4
|
-
<tiny-form-item label="字典名称" prop="name">
|
|
5
|
-
<tiny-input v-model="$Data.formData.name" placeholder="请输入字典名称" />
|
|
6
|
-
</tiny-form-item>
|
|
7
|
-
<tiny-form-item label="字典代码" prop="code">
|
|
8
|
-
<tiny-input v-model="$Data.formData.code" placeholder="请输入字典代码,如:gender" />
|
|
9
|
-
</tiny-form-item>
|
|
10
|
-
<tiny-form-item label="字典值" prop="value">
|
|
11
|
-
<tiny-input v-model="$Data.formData.value" placeholder="请输入字典值" />
|
|
12
|
-
</tiny-form-item>
|
|
13
|
-
<tiny-form-item label="父级ID" prop="pid">
|
|
14
|
-
<tiny-numeric v-model="$Data.formData.pid" :min="0" :max="999999999999999" />
|
|
15
|
-
</tiny-form-item>
|
|
16
|
-
<tiny-form-item label="排序" prop="sort">
|
|
17
|
-
<tiny-numeric v-model="$Data.formData.sort" :min="0" :max="9999" />
|
|
18
|
-
</tiny-form-item>
|
|
19
|
-
<tiny-form-item label="描述" prop="description">
|
|
20
|
-
<tiny-input v-model="$Data.formData.description" type="textarea" placeholder="请输入描述" :rows="3" />
|
|
21
|
-
</tiny-form-item>
|
|
22
|
-
<tiny-form-item label="状态" prop="state">
|
|
23
|
-
<tiny-radio-group v-model="$Data.formData.state">
|
|
24
|
-
<tiny-radio :label="1">正常</tiny-radio>
|
|
25
|
-
<tiny-radio :label="2">禁用</tiny-radio>
|
|
26
|
-
</tiny-radio-group>
|
|
27
|
-
</tiny-form-item>
|
|
28
|
-
</tiny-form>
|
|
29
|
-
<template #footer>
|
|
30
|
-
<tiny-button @click="$Method.onClose">取消</tiny-button>
|
|
31
|
-
<tiny-button type="primary" @click="$Method.onSubmit">确定</tiny-button>
|
|
32
|
-
</template>
|
|
33
|
-
</tiny-dialog-box>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<script setup>
|
|
37
|
-
const $Prop = defineProps({
|
|
38
|
-
modelValue: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: false
|
|
41
|
-
},
|
|
42
|
-
actionType: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: 'add'
|
|
45
|
-
},
|
|
46
|
-
rowData: {
|
|
47
|
-
type: Object,
|
|
48
|
-
default: {}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const $Emit = defineEmits(['update:modelValue', 'success']);
|
|
53
|
-
|
|
54
|
-
// 表单引用
|
|
55
|
-
const $From = $shallowRef({
|
|
56
|
-
form: null
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const $Data = $ref({
|
|
60
|
-
visible: false,
|
|
61
|
-
formData: {
|
|
62
|
-
id: 0,
|
|
63
|
-
name: '',
|
|
64
|
-
code: '',
|
|
65
|
-
value: '',
|
|
66
|
-
pid: 0,
|
|
67
|
-
sort: 0,
|
|
68
|
-
description: '',
|
|
69
|
-
state: 1
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const $Data2 = $shallowRef({
|
|
74
|
-
formRules: {
|
|
75
|
-
name: [{ required: true, message: '请输入字典名称', trigger: 'blur' }],
|
|
76
|
-
code: [
|
|
77
|
-
{ required: true, message: '请输入字典代码', trigger: 'blur' },
|
|
78
|
-
{ pattern: /^[a-zA-Z0-9_]+$/, message: '字典代码只能包含字母、数字和下划线', trigger: 'blur' }
|
|
79
|
-
],
|
|
80
|
-
value: [{ required: true, message: '请输入字典值', trigger: 'blur' }]
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// 方法集合
|
|
85
|
-
const $Method = {
|
|
86
|
-
async initData() {
|
|
87
|
-
$Method.onShow();
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
onShow() {
|
|
91
|
-
$Data.visible = true;
|
|
92
|
-
if ($Prop.actionType === 'upd' && $Prop.rowData) {
|
|
93
|
-
$Data.formData.id = $Prop.rowData.id || 0;
|
|
94
|
-
$Data.formData.name = $Prop.rowData.name || '';
|
|
95
|
-
$Data.formData.code = $Prop.rowData.code || '';
|
|
96
|
-
$Data.formData.value = $Prop.rowData.value || '';
|
|
97
|
-
$Data.formData.pid = $Prop.rowData.pid || 0;
|
|
98
|
-
$Data.formData.sort = $Prop.rowData.sort || 0;
|
|
99
|
-
$Data.formData.description = $Prop.rowData.description || '';
|
|
100
|
-
$Data.formData.state = $Prop.rowData.state ?? 1;
|
|
101
|
-
} else {
|
|
102
|
-
// 重置表单
|
|
103
|
-
$Data.formData.id = 0;
|
|
104
|
-
$Data.formData.name = '';
|
|
105
|
-
$Data.formData.code = '';
|
|
106
|
-
$Data.formData.value = '';
|
|
107
|
-
$Data.formData.pid = 0;
|
|
108
|
-
$Data.formData.sort = 0;
|
|
109
|
-
$Data.formData.description = '';
|
|
110
|
-
$Data.formData.state = 1;
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
onClose() {
|
|
115
|
-
$Data.visible = false;
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
$Emit('update:modelValue', false);
|
|
118
|
-
}, 300);
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
async onSubmit() {
|
|
122
|
-
try {
|
|
123
|
-
const valid = await $From.form.validate();
|
|
124
|
-
if (!valid) return;
|
|
125
|
-
|
|
126
|
-
const res = await $Http($Prop.actionType === 'add' ? '/addon/admin/dictIns' : '/addon/admin/dictUpd', $Data.formData);
|
|
127
|
-
|
|
128
|
-
Modal.message({
|
|
129
|
-
message: $Prop.actionType === 'add' ? '添加成功' : '编辑成功',
|
|
130
|
-
status: 'success'
|
|
131
|
-
});
|
|
132
|
-
$Method.onClose();
|
|
133
|
-
$Emit('success');
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.error('提交失败:', error);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// 监听 modelValue 变化
|
|
141
|
-
watch(
|
|
142
|
-
() => $Prop.modelValue,
|
|
143
|
-
(val) => {
|
|
144
|
-
if (val && !$Data.visible) {
|
|
145
|
-
$Method.initData();
|
|
146
|
-
} else if (!val && $Data.visible) {
|
|
147
|
-
$Data.visible = false;
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{ immediate: true }
|
|
151
|
-
);
|
|
152
|
-
</script>
|
|
153
|
-
|
|
154
|
-
<style scoped lang="scss">
|
|
155
|
-
// 可根据需要添加样式
|
|
156
|
-
</style>
|