befly-admin 3.4.6 → 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.
Files changed (65) hide show
  1. package/.gitignore +2 -0
  2. package/index.html +2 -2
  3. package/package.json +8 -8
  4. package/src/config/{internal/index.ts → index.ts} +1 -1
  5. package/src/layouts/{internal/0.vue → default.vue} +49 -20
  6. package/src/main.ts +3 -5
  7. package/src/plugins/{internal/global.ts → global.ts} +1 -11
  8. package/src/plugins/{internal/http.ts → http.ts} +1 -1
  9. package/src/{plugins/internal/router.ts → router/index.ts} +22 -15
  10. package/src/styles/{internal/index.scss → global.scss} +29 -29
  11. package/src/types/auto-imports.d.ts +90 -645
  12. package/src/types/components.d.ts +5 -23
  13. package/src/types/typed-router.d.ts +32 -0
  14. package/src/utils/index.ts +21 -9
  15. package/src/views/index.vue +27 -0
  16. package/src/views/internal/login.vue +73 -0
  17. package/src/views/test.vue +60 -0
  18. package/tsconfig.json +4 -4
  19. package/vite.config.ts +123 -44
  20. package/src/components/internal/README.md +0 -27
  21. package/src/layouts/4.vue +0 -17
  22. package/src/layouts/internal/1.vue +0 -22
  23. package/src/layouts/internal/2.vue +0 -169
  24. package/src/layouts/internal/README.md +0 -27
  25. package/src/plugins/internal/README.md +0 -36
  26. package/src/styles/internal/README.md +0 -27
  27. package/src/styles/internal/mixins.scss +0 -98
  28. package/src/types/env.d.ts +0 -23
  29. package/src/utils/README.md +0 -37
  30. package/src/utils/internal/README.md +0 -21
  31. package/src/utils/internal/index.ts +0 -30
  32. package/src/views/internal/403/403.vue +0 -66
  33. package/src/views/internal/README.md +0 -27
  34. package/src/views/internal/admin/components/edit.vue +0 -147
  35. package/src/views/internal/admin/components/role.vue +0 -135
  36. package/src/views/internal/admin/index.vue +0 -176
  37. package/src/views/internal/dict/components/edit.vue +0 -156
  38. package/src/views/internal/dict/index.vue +0 -159
  39. package/src/views/internal/index/components/addonList.vue +0 -125
  40. package/src/views/internal/index/components/environmentInfo.vue +0 -97
  41. package/src/views/internal/index/components/operationLogs.vue +0 -112
  42. package/src/views/internal/index/components/performanceMetrics.vue +0 -148
  43. package/src/views/internal/index/components/quickActions.vue +0 -27
  44. package/src/views/internal/index/components/serviceStatus.vue +0 -181
  45. package/src/views/internal/index/components/systemNotifications.vue +0 -130
  46. package/src/views/internal/index/components/systemOverview.vue +0 -188
  47. package/src/views/internal/index/components/systemResources.vue +0 -104
  48. package/src/views/internal/index/components/userInfo.vue +0 -202
  49. package/src/views/internal/index/index.vue +0 -62
  50. package/src/views/internal/login/components/emailLoginForm.vue +0 -163
  51. package/src/views/internal/login/components/registerForm.vue +0 -168
  52. package/src/views/internal/login/components/welcomePanel.vue +0 -61
  53. package/src/views/internal/login/index_1.vue +0 -189
  54. package/src/views/internal/menu/components/edit.vue +0 -150
  55. package/src/views/internal/menu/index.vue +0 -168
  56. package/src/views/internal/news/detail/detail_2.vue +0 -26
  57. package/src/views/internal/news/detail/index.vue +0 -26
  58. package/src/views/internal/news/news.vue +0 -26
  59. package/src/views/internal/role/components/api.vue +0 -280
  60. package/src/views/internal/role/components/edit.vue +0 -129
  61. package/src/views/internal/role/components/menu.vue +0 -143
  62. package/src/views/internal/role/index.vue +0 -179
  63. package/src/views/internal/user/user.vue +0 -320
  64. /package/src/plugins/{internal/storage.ts → storage.ts} +0 -0
  65. /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,176 +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
- <i-lucide:plus style="width: 16px; height: 16px" />
8
- </template>
9
- 添加管理员
10
- </tiny-button>
11
- </div>
12
- <div class="right">
13
- <tiny-button @click="$Method.handleRefresh">
14
- <template #icon>
15
- <i-lucide:rotate-cw style="width: 16px; height: 16px" />
16
- </template>
17
- </tiny-button>
18
- </div>
19
- <div class="right">
20
- <tiny-button @click="$Method.handleRefresh">
21
- <template #icon>
22
- <i-lucide:rotate-cw style="width: 16px; height: 16px" />
23
- </template>
24
- 刷新
25
- </tiny-button>
26
- </div>
27
- </div>
28
-
29
- <div class="main-table">
30
- <tiny-grid :data="$Data.tableData" header-cell-class-name="custom-table-cell-class" size="small" height="100%" seq-serial>
31
- <tiny-grid-column type="index" title="序号" :width="60" />
32
- <tiny-grid-column field="username" title="用户名" />
33
- <tiny-grid-column field="email" title="邮箱" :width="200" />
34
- <tiny-grid-column field="nickname" title="昵称" :width="150" />
35
- <tiny-grid-column field="roleCode" title="角色" :width="120" />
36
- <tiny-grid-column field="state" title="状态" :width="100">
37
- <template #default="{ row }">
38
- <tiny-tag v-if="row.state === 1" type="success">正常</tiny-tag>
39
- <tiny-tag v-else-if="row.state === 2" type="warning">禁用</tiny-tag>
40
- <tiny-tag v-else type="danger">已删除</tiny-tag>
41
- </template>
42
- </tiny-grid-column>
43
- <tiny-grid-column title="操作" :width="120" align="right">
44
- <template #default="{ row }">
45
- <tiny-dropdown title="操作" trigger="click" size="small" border visible-arrow @item-click="(data) => $Method.onAction(data.itemData.command, row)">
46
- <template #dropdown>
47
- <tiny-dropdown-menu>
48
- <tiny-dropdown-item :item-data="{ command: 'role' }">
49
- <i-lucide:user style="width: 14px; height: 14px; margin-right: 6px" />
50
- 分配角色
51
- </tiny-dropdown-item>
52
- <tiny-dropdown-item :item-data="{ command: 'upd' }">
53
- <i-lucide:pencil style="width: 14px; height: 14px; margin-right: 6px" />
54
- 编辑
55
- </tiny-dropdown-item>
56
- <tiny-dropdown-item :item-data="{ command: 'del' }" divided>
57
- <i-lucide:trash-2 style="width: 14px; height: 14px; margin-right: 6px" />
58
- 删除
59
- </tiny-dropdown-item>
60
- </tiny-dropdown-menu>
61
- </template>
62
- </tiny-dropdown>
63
- </template>
64
- </tiny-grid-column>
65
- </tiny-grid>
66
- </div>
67
-
68
- <div class="main-page">
69
- <tiny-pager :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.pageSize" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @size-change="$Method.handleSizeChange" />
70
- </div>
71
-
72
- <!-- 编辑对话框组件 -->
73
- <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.apiAdminList" />
74
-
75
- <!-- 角色分配对话框组件 -->
76
- <RoleDialog v-if="$Data.roleVisible" v-model="$Data.roleVisible" :row-data="$Data.rowData" @success="$Method.apiAdminList" />
77
- </div>
78
- </template>
79
-
80
- <script setup>
81
- import EditDialog from './components/edit.vue';
82
- import RoleDialog from './components/role.vue';
83
-
84
- // 响应式数据
85
- const $Data = $ref({
86
- tableData: [],
87
- pagerConfig: {
88
- currentPage: 1,
89
- pageSize: 30,
90
- total: 0,
91
- align: 'right',
92
- layout: 'total, prev, pager, next, jumper'
93
- },
94
- editVisible: false,
95
- roleVisible: false,
96
- actionType: 'add',
97
- rowData: {}
98
- });
99
-
100
- // 方法
101
- const $Method = {
102
- async initData() {
103
- await $Method.apiAdminList();
104
- },
105
-
106
- // 加载管理员列表
107
- async apiAdminList() {
108
- try {
109
- const res = await $Http('/addon/admin/list', {
110
- page: $Data.pagerConfig.currentPage,
111
- limit: $Data.pagerConfig.pageSize
112
- });
113
- $Data.tableData = res.data.lists || [];
114
- $Data.pagerConfig.total = res.data.total || 0;
115
- } catch (error) {
116
- console.error('加载管理员列表失败:', error);
117
- Modal.message({
118
- message: '加载数据失败',
119
- status: 'error'
120
- });
121
- }
122
- },
123
-
124
- // 删除管理员
125
- async apiAdminDel(row) {
126
- Modal.confirm({
127
- header: '确认删除',
128
- body: `确定要删除管理员"${row.username}" 吗?`,
129
- status: 'warning'
130
- }).then(async () => {
131
- try {
132
- const res = await $Http('/addon/admin/del', { id: row.id });
133
- if (res.code === 0) {
134
- Modal.message({ message: '删除成功', status: 'success' });
135
- $Method.apiAdminList();
136
- } else {
137
- Modal.message({ message: res.msg || '删除失败', status: 'error' });
138
- }
139
- } catch (error) {
140
- console.error('删除失败:', error);
141
- Modal.message({ message: '删除失败', status: 'error' });
142
- }
143
- });
144
- },
145
-
146
- // 刷新
147
- handleRefresh() {
148
- $Method.apiAdminList();
149
- },
150
-
151
- // 分页改变
152
- onPageChange({ currentPage }) {
153
- $Data.pagerConfig.currentPage = currentPage;
154
- $Method.apiAdminList();
155
- },
156
-
157
- // 操作菜单点击
158
- onAction(command, rowData) {
159
- $Data.actionType = command;
160
- $Data.rowData = rowData;
161
- if (command === 'add' || command === 'upd') {
162
- $Data.editVisible = true;
163
- } else if (command === 'role') {
164
- $Data.roleVisible = true;
165
- } else if (command === 'del') {
166
- $Method.apiAdminDel(rowData);
167
- }
168
- }
169
- };
170
-
171
- $Method.initData();
172
- </script>
173
-
174
- <style scoped lang="scss">
175
- // 样式继承自全局 page-table
176
- </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>