zant-admin 2.0.2 → 2.0.4
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/.editorconfig +6 -0
- package/.env.development +3 -0
- package/.env.production +1 -0
- package/.env.test +1 -0
- package/.gitignore +36 -0
- package/.prettierrc.json +9 -0
- package/README.en.md +461 -272
- package/README.md +4 -3
- package/bin/cli.js +1 -1
- package/eslint.config.js +30 -0
- package/index.html +13 -0
- package/jsconfig.json +8 -0
- package/package.json +11 -3
- package/src/App.vue +16 -16
- package/src/api/methods/logError.js +8 -8
- package/src/api/methods/logOperation.js +8 -8
- package/src/api/methods/login.js +6 -6
- package/src/api/methods/quartz.js +36 -36
- package/src/api/methods/region.js +16 -16
- package/src/api/methods/sysAccount.js +29 -29
- package/src/api/methods/sysDict.js +29 -29
- package/src/api/methods/sysDictItem.js +26 -26
- package/src/api/methods/sysMenu.js +42 -42
- package/src/api/methods/sysRole.js +35 -35
- package/src/api/methods/sysUser.js +25 -25
- package/src/api/methods/system.js +15 -15
- package/src/api/request.js +225 -225
- package/src/assets/css/zcui.css +1023 -1023
- package/src/components/IconPicker.vue +351 -351
- package/src/components/MainPage.vue +838 -838
- package/src/components/details/logErrorDetails.vue +58 -58
- package/src/components/details/logOperationDetails.vue +76 -76
- package/src/components/edit/QuartzEdit.vue +221 -221
- package/src/components/edit/SysAccountEdit.vue +185 -185
- package/src/components/edit/SysDictEdit.vue +116 -116
- package/src/components/edit/SysDictItemEdit.vue +136 -136
- package/src/components/edit/SysRoleEdit.vue +111 -111
- package/src/config/index.js +74 -74
- package/src/directives/permission.js +49 -49
- package/src/main.js +37 -37
- package/src/stores/config.js +43 -43
- package/src/stores/dict.js +33 -33
- package/src/stores/menu.js +81 -81
- package/src/stores/user.js +21 -21
- package/src/utils/baseEcharts.js +661 -661
- package/src/utils/dictTemplate.js +26 -26
- package/src/utils/regionUtils.js +173 -173
- package/src/utils/useFormCRUD.js +59 -59
- package/src/views/baiscstatis/center.vue +474 -474
- package/src/views/baiscstatis/iframePage.vue +29 -29
- package/src/views/baiscstatis/notFound.vue +192 -192
- package/src/views/console.vue +821 -821
- package/src/views/demo/button.vue +269 -269
- package/src/views/demo/importexport.vue +119 -119
- package/src/views/demo/region.vue +322 -322
- package/src/views/demo/statistics.vue +214 -214
- package/src/views/home.vue +6 -6
- package/src/views/operations/log/logError.vue +78 -78
- package/src/views/operations/log/logLogin.vue +66 -66
- package/src/views/operations/log/logOperation.vue +103 -103
- package/src/views/operations/log/logQuartz.vue +56 -56
- package/src/views/operations/quartz.vue +179 -179
- package/src/views/operations/serviceMonitoring.vue +134 -134
- package/src/views/system/sysAccount.vue +128 -128
- package/src/views/system/sysDict.vue +159 -159
- package/src/views/system/sysDictItem.vue +118 -118
- package/src/views/system/sysMenu.vue +225 -225
- package/src/views/system/sysRole.vue +207 -207
- package/vite.config.js +33 -0
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a-drawer
|
|
3
|
-
:title="editTitle"
|
|
4
|
-
:width="540"
|
|
5
|
-
:open="open"
|
|
6
|
-
:body-style="{ paddingBottom: '80px' }"
|
|
7
|
-
:footer-style="{ textAlign: 'right' }"
|
|
8
|
-
@close="onClose"
|
|
9
|
-
:destroyOnClose="true"
|
|
10
|
-
>
|
|
11
|
-
<a-form :model="formInfo" ref="formRef" layout="vertical">
|
|
12
|
-
<a-form-item
|
|
13
|
-
label="账号名称"
|
|
14
|
-
name="name"
|
|
15
|
-
:rules="[{ required: true, message: '账号名称不能为空' }]"
|
|
16
|
-
>
|
|
17
|
-
<a-input v-model:value="formInfo.name" placeholder="请输入" />
|
|
18
|
-
</a-form-item>
|
|
19
|
-
<a-form-item
|
|
20
|
-
label="手机号"
|
|
21
|
-
name="mobile"
|
|
22
|
-
:rules="[{ required: true, message: '手机号不能为空' }]"
|
|
23
|
-
>
|
|
24
|
-
<a-input-number
|
|
25
|
-
v-model:value="formInfo.mobile"
|
|
26
|
-
placeholder="请输入"
|
|
27
|
-
style="width: 100%"
|
|
28
|
-
/>
|
|
29
|
-
</a-form-item>
|
|
30
|
-
<a-form-item
|
|
31
|
-
label="密码"
|
|
32
|
-
name="password"
|
|
33
|
-
v-if="formInfo.id == 0"
|
|
34
|
-
:rules="[{ required: true, message: '密码不能为空' }]"
|
|
35
|
-
>
|
|
36
|
-
<a-input-password
|
|
37
|
-
v-model:value="formInfo.password"
|
|
38
|
-
placeholder="请输入"
|
|
39
|
-
/>
|
|
40
|
-
</a-form-item>
|
|
41
|
-
<a-form-item
|
|
42
|
-
label="角色"
|
|
43
|
-
name="roleId"
|
|
44
|
-
:rules="[{ required: true, message: '请选择角色' }]"
|
|
45
|
-
>
|
|
46
|
-
<a-select
|
|
47
|
-
v-model:value="formInfo.roleId"
|
|
48
|
-
placeholder="请选择"
|
|
49
|
-
:options="roleList"
|
|
50
|
-
>
|
|
51
|
-
</a-select>
|
|
52
|
-
</a-form-item>
|
|
53
|
-
<a-form-item label="邮件" name="email">
|
|
54
|
-
<a-input v-model:value="formInfo.email" placeholder="请输入" />
|
|
55
|
-
</a-form-item>
|
|
56
|
-
|
|
57
|
-
<a-form-item label="是否启用" name="isEnable">
|
|
58
|
-
<a-switch v-model:checked="formInfo.isEnable" />
|
|
59
|
-
</a-form-item>
|
|
60
|
-
<a-form-item label="备注" name="remark">
|
|
61
|
-
<a-textarea v-model:value="formInfo.remark" />
|
|
62
|
-
</a-form-item>
|
|
63
|
-
</a-form>
|
|
64
|
-
|
|
65
|
-
<template #extra>
|
|
66
|
-
<a-space>
|
|
67
|
-
<a-button type="primary" @click="onSave" :loading="loading"
|
|
68
|
-
>保存</a-button
|
|
69
|
-
>
|
|
70
|
-
<a-button @click="resetForm">重置</a-button>
|
|
71
|
-
</a-space>
|
|
72
|
-
</template>
|
|
73
|
-
</a-drawer>
|
|
74
|
-
</template>
|
|
75
|
-
|
|
76
|
-
<script setup>
|
|
77
|
-
import { defineProps, defineEmits, ref, reactive, onMounted } from 'vue'
|
|
78
|
-
import { message } from 'ant-design-vue'
|
|
79
|
-
import sysRole from '@/api/methods/sysRole'
|
|
80
|
-
import sysAccount from '@/api/methods/sysAccount'
|
|
81
|
-
import useFormCRUD from '@/utils/useFormCRUD'
|
|
82
|
-
|
|
83
|
-
const props = defineProps({
|
|
84
|
-
open: {
|
|
85
|
-
type: Boolean,
|
|
86
|
-
required: true,
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
// 表单字段的默认值
|
|
91
|
-
const defaultformInfo = {
|
|
92
|
-
id: null,
|
|
93
|
-
name: '',
|
|
94
|
-
mobile: '',
|
|
95
|
-
password: '',
|
|
96
|
-
email: '',
|
|
97
|
-
roleId: null,
|
|
98
|
-
isEnable: true,
|
|
99
|
-
remark: '',
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// 响应式数据
|
|
103
|
-
const formInfo = reactive({ ...defaultformInfo })
|
|
104
|
-
const editTitle = ref('新增')
|
|
105
|
-
const formRef = ref(null)
|
|
106
|
-
const roleList = ref([])
|
|
107
|
-
|
|
108
|
-
// 定义 emits,用于触发关闭事件
|
|
109
|
-
const emit = defineEmits(['close', 'updateData'])
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* 重置表单到默认值
|
|
113
|
-
*/
|
|
114
|
-
const resetForm = () => {
|
|
115
|
-
Object.assign(formInfo, defaultformInfo)
|
|
116
|
-
formRef.value?.resetFields()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const { loading, save } = useFormCRUD(sysAccount)
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 初始化账号编辑表单
|
|
123
|
-
* @param {number} id - 账号ID,如果为0或空则表示新增账号
|
|
124
|
-
*/
|
|
125
|
-
const init = async id => {
|
|
126
|
-
const isEdit = !!id
|
|
127
|
-
editTitle.value = isEdit ? '修改' : '新增'
|
|
128
|
-
|
|
129
|
-
if (isEdit) {
|
|
130
|
-
try {
|
|
131
|
-
const res = await sysAccount.get({ id })
|
|
132
|
-
Object.assign(formInfo, res.data)
|
|
133
|
-
} catch (error) {
|
|
134
|
-
message.error('获取信息失败,请重试')
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
resetForm()
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 加载角色列表
|
|
143
|
-
*/
|
|
144
|
-
const loadRoleList = async () => {
|
|
145
|
-
try {
|
|
146
|
-
const res = await sysRole.getList()
|
|
147
|
-
roleList.value = res.data.map(x => ({
|
|
148
|
-
label: x.name,
|
|
149
|
-
value: x.id,
|
|
150
|
-
}))
|
|
151
|
-
} catch (error) {
|
|
152
|
-
message.error('加载角色列表失败,请重试')
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* 保存账号信息
|
|
158
|
-
* 处理表单验证账号新增/修改操作
|
|
159
|
-
*/
|
|
160
|
-
const onSave = async () => {
|
|
161
|
-
await save(formRef.value, formInfo, {
|
|
162
|
-
onSuccess: () => {
|
|
163
|
-
emit('updateData')
|
|
164
|
-
onClose()
|
|
165
|
-
},
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* 关闭抽屉组件
|
|
171
|
-
* 触发关闭事件并通知父组件
|
|
172
|
-
*/
|
|
173
|
-
const onClose = () => {
|
|
174
|
-
resetForm()
|
|
175
|
-
emit('close')
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// 组件挂载时加载角色列表
|
|
179
|
-
onMounted(() => {
|
|
180
|
-
loadRoleList()
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
// 使用 defineExpose 暴露方法
|
|
184
|
-
defineExpose({ init })
|
|
185
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<a-drawer
|
|
3
|
+
:title="editTitle"
|
|
4
|
+
:width="540"
|
|
5
|
+
:open="open"
|
|
6
|
+
:body-style="{ paddingBottom: '80px' }"
|
|
7
|
+
:footer-style="{ textAlign: 'right' }"
|
|
8
|
+
@close="onClose"
|
|
9
|
+
:destroyOnClose="true"
|
|
10
|
+
>
|
|
11
|
+
<a-form :model="formInfo" ref="formRef" layout="vertical">
|
|
12
|
+
<a-form-item
|
|
13
|
+
label="账号名称"
|
|
14
|
+
name="name"
|
|
15
|
+
:rules="[{ required: true, message: '账号名称不能为空' }]"
|
|
16
|
+
>
|
|
17
|
+
<a-input v-model:value="formInfo.name" placeholder="请输入" />
|
|
18
|
+
</a-form-item>
|
|
19
|
+
<a-form-item
|
|
20
|
+
label="手机号"
|
|
21
|
+
name="mobile"
|
|
22
|
+
:rules="[{ required: true, message: '手机号不能为空' }]"
|
|
23
|
+
>
|
|
24
|
+
<a-input-number
|
|
25
|
+
v-model:value="formInfo.mobile"
|
|
26
|
+
placeholder="请输入"
|
|
27
|
+
style="width: 100%"
|
|
28
|
+
/>
|
|
29
|
+
</a-form-item>
|
|
30
|
+
<a-form-item
|
|
31
|
+
label="密码"
|
|
32
|
+
name="password"
|
|
33
|
+
v-if="formInfo.id == 0"
|
|
34
|
+
:rules="[{ required: true, message: '密码不能为空' }]"
|
|
35
|
+
>
|
|
36
|
+
<a-input-password
|
|
37
|
+
v-model:value="formInfo.password"
|
|
38
|
+
placeholder="请输入"
|
|
39
|
+
/>
|
|
40
|
+
</a-form-item>
|
|
41
|
+
<a-form-item
|
|
42
|
+
label="角色"
|
|
43
|
+
name="roleId"
|
|
44
|
+
:rules="[{ required: true, message: '请选择角色' }]"
|
|
45
|
+
>
|
|
46
|
+
<a-select
|
|
47
|
+
v-model:value="formInfo.roleId"
|
|
48
|
+
placeholder="请选择"
|
|
49
|
+
:options="roleList"
|
|
50
|
+
>
|
|
51
|
+
</a-select>
|
|
52
|
+
</a-form-item>
|
|
53
|
+
<a-form-item label="邮件" name="email">
|
|
54
|
+
<a-input v-model:value="formInfo.email" placeholder="请输入" />
|
|
55
|
+
</a-form-item>
|
|
56
|
+
|
|
57
|
+
<a-form-item label="是否启用" name="isEnable">
|
|
58
|
+
<a-switch v-model:checked="formInfo.isEnable" />
|
|
59
|
+
</a-form-item>
|
|
60
|
+
<a-form-item label="备注" name="remark">
|
|
61
|
+
<a-textarea v-model:value="formInfo.remark" />
|
|
62
|
+
</a-form-item>
|
|
63
|
+
</a-form>
|
|
64
|
+
|
|
65
|
+
<template #extra>
|
|
66
|
+
<a-space>
|
|
67
|
+
<a-button type="primary" @click="onSave" :loading="loading"
|
|
68
|
+
>保存</a-button
|
|
69
|
+
>
|
|
70
|
+
<a-button @click="resetForm">重置</a-button>
|
|
71
|
+
</a-space>
|
|
72
|
+
</template>
|
|
73
|
+
</a-drawer>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script setup>
|
|
77
|
+
import { defineProps, defineEmits, ref, reactive, onMounted } from 'vue'
|
|
78
|
+
import { message } from 'ant-design-vue'
|
|
79
|
+
import sysRole from '@/api/methods/sysRole'
|
|
80
|
+
import sysAccount from '@/api/methods/sysAccount'
|
|
81
|
+
import useFormCRUD from '@/utils/useFormCRUD'
|
|
82
|
+
|
|
83
|
+
const props = defineProps({
|
|
84
|
+
open: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
required: true,
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// 表单字段的默认值
|
|
91
|
+
const defaultformInfo = {
|
|
92
|
+
id: null,
|
|
93
|
+
name: '',
|
|
94
|
+
mobile: '',
|
|
95
|
+
password: '',
|
|
96
|
+
email: '',
|
|
97
|
+
roleId: null,
|
|
98
|
+
isEnable: true,
|
|
99
|
+
remark: '',
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 响应式数据
|
|
103
|
+
const formInfo = reactive({ ...defaultformInfo })
|
|
104
|
+
const editTitle = ref('新增')
|
|
105
|
+
const formRef = ref(null)
|
|
106
|
+
const roleList = ref([])
|
|
107
|
+
|
|
108
|
+
// 定义 emits,用于触发关闭事件
|
|
109
|
+
const emit = defineEmits(['close', 'updateData'])
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 重置表单到默认值
|
|
113
|
+
*/
|
|
114
|
+
const resetForm = () => {
|
|
115
|
+
Object.assign(formInfo, defaultformInfo)
|
|
116
|
+
formRef.value?.resetFields()
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const { loading, save } = useFormCRUD(sysAccount)
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 初始化账号编辑表单
|
|
123
|
+
* @param {number} id - 账号ID,如果为0或空则表示新增账号
|
|
124
|
+
*/
|
|
125
|
+
const init = async id => {
|
|
126
|
+
const isEdit = !!id
|
|
127
|
+
editTitle.value = isEdit ? '修改' : '新增'
|
|
128
|
+
|
|
129
|
+
if (isEdit) {
|
|
130
|
+
try {
|
|
131
|
+
const res = await sysAccount.get({ id })
|
|
132
|
+
Object.assign(formInfo, res.data)
|
|
133
|
+
} catch (error) {
|
|
134
|
+
message.error('获取信息失败,请重试')
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
resetForm()
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 加载角色列表
|
|
143
|
+
*/
|
|
144
|
+
const loadRoleList = async () => {
|
|
145
|
+
try {
|
|
146
|
+
const res = await sysRole.getList()
|
|
147
|
+
roleList.value = res.data.map(x => ({
|
|
148
|
+
label: x.name,
|
|
149
|
+
value: x.id,
|
|
150
|
+
}))
|
|
151
|
+
} catch (error) {
|
|
152
|
+
message.error('加载角色列表失败,请重试')
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 保存账号信息
|
|
158
|
+
* 处理表单验证账号新增/修改操作
|
|
159
|
+
*/
|
|
160
|
+
const onSave = async () => {
|
|
161
|
+
await save(formRef.value, formInfo, {
|
|
162
|
+
onSuccess: () => {
|
|
163
|
+
emit('updateData')
|
|
164
|
+
onClose()
|
|
165
|
+
},
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 关闭抽屉组件
|
|
171
|
+
* 触发关闭事件并通知父组件
|
|
172
|
+
*/
|
|
173
|
+
const onClose = () => {
|
|
174
|
+
resetForm()
|
|
175
|
+
emit('close')
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 组件挂载时加载角色列表
|
|
179
|
+
onMounted(() => {
|
|
180
|
+
loadRoleList()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
// 使用 defineExpose 暴露方法
|
|
184
|
+
defineExpose({ init })
|
|
185
|
+
</script>
|
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a-drawer
|
|
3
|
-
:title="editTitle"
|
|
4
|
-
:width="540"
|
|
5
|
-
:open="open"
|
|
6
|
-
:body-style="{ paddingBottom: '80px' }"
|
|
7
|
-
:footer-style="{ textAlign: 'right' }"
|
|
8
|
-
@close="onClose"
|
|
9
|
-
:destroyOnClose="true"
|
|
10
|
-
>
|
|
11
|
-
<a-form :model="formInfo" ref="formRef" layout="vertical">
|
|
12
|
-
<a-form-item
|
|
13
|
-
label="字典名称"
|
|
14
|
-
name="name"
|
|
15
|
-
:rules="[{ required: true, message: '字典名称不能为空' }]"
|
|
16
|
-
>
|
|
17
|
-
<a-input v-model:value="formInfo.name" placeholder="请输入" />
|
|
18
|
-
</a-form-item>
|
|
19
|
-
<a-form-item
|
|
20
|
-
label="字典类型"
|
|
21
|
-
name="type"
|
|
22
|
-
:rules="[{ required: true, message: '字典类型不能为空' }]"
|
|
23
|
-
>
|
|
24
|
-
<a-input v-model:value="formInfo.type" placeholder="请输入" />
|
|
25
|
-
</a-form-item>
|
|
26
|
-
<a-form-item label="是否启用" name="isEnable">
|
|
27
|
-
<a-switch v-model:checked="formInfo.isEnable" />
|
|
28
|
-
</a-form-item>
|
|
29
|
-
<a-form-item label="备注" name="remark">
|
|
30
|
-
<a-textarea v-model:value="formInfo.remark" />
|
|
31
|
-
</a-form-item>
|
|
32
|
-
</a-form>
|
|
33
|
-
<template #extra>
|
|
34
|
-
<a-space>
|
|
35
|
-
<a-button type="primary" @click="onSave" :loading="loading"
|
|
36
|
-
>保存</a-button
|
|
37
|
-
>
|
|
38
|
-
<a-button @click="resetForm">重置</a-button>
|
|
39
|
-
</a-space>
|
|
40
|
-
</template>
|
|
41
|
-
</a-drawer>
|
|
42
|
-
</template>
|
|
43
|
-
<script setup>
|
|
44
|
-
import { defineProps, defineEmits, ref, reactive } from 'vue'
|
|
45
|
-
import { message } from 'ant-design-vue'
|
|
46
|
-
import sysDict from '@/api/methods/sysDict'
|
|
47
|
-
import useFormCRUD from '@/utils/useFormCRUD'
|
|
48
|
-
const props = defineProps({
|
|
49
|
-
open: {
|
|
50
|
-
type: Boolean,
|
|
51
|
-
required: true,
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
const defaultformInfo = {
|
|
55
|
-
id: null,
|
|
56
|
-
name: '',
|
|
57
|
-
type: '',
|
|
58
|
-
isEnable: true,
|
|
59
|
-
remark: '',
|
|
60
|
-
}
|
|
61
|
-
// 使用 reactive 定义表单状态
|
|
62
|
-
const formInfo = reactive({ ...defaultformInfo })
|
|
63
|
-
const editTitle = ref('新增')
|
|
64
|
-
const formRef = ref(null)
|
|
65
|
-
// 定义 emits,用于触发关闭事件
|
|
66
|
-
const emit = defineEmits(['close', 'updateData'])
|
|
67
|
-
/**
|
|
68
|
-
* 重置表单到默认值
|
|
69
|
-
*/
|
|
70
|
-
const resetForm = () => {
|
|
71
|
-
Object.assign(formInfo, defaultformInfo)
|
|
72
|
-
formRef.value?.resetFields()
|
|
73
|
-
}
|
|
74
|
-
const { loading, save } = useFormCRUD(sysDict)
|
|
75
|
-
/**
|
|
76
|
-
* 初始化角色编辑表单
|
|
77
|
-
* @param {number} id - 角色ID,如果为0或空则表示新增角色
|
|
78
|
-
*/
|
|
79
|
-
const init = async id => {
|
|
80
|
-
const isEdit = !!id
|
|
81
|
-
editTitle.value = isEdit ? '修改' : '新增'
|
|
82
|
-
|
|
83
|
-
if (isEdit) {
|
|
84
|
-
try {
|
|
85
|
-
const res = await sysDict.get({ id })
|
|
86
|
-
Object.assign(formInfo, res.data)
|
|
87
|
-
} catch (error) {
|
|
88
|
-
message.error('获取信息失败,请重试')
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
resetForm()
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 保存
|
|
96
|
-
* 处理表单验证和角色新增/修改操作
|
|
97
|
-
*/
|
|
98
|
-
const onSave = async () => {
|
|
99
|
-
await save(formRef.value, formInfo, {
|
|
100
|
-
onSuccess: () => {
|
|
101
|
-
emit('updateData')
|
|
102
|
-
onClose()
|
|
103
|
-
},
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 关闭抽屉组件
|
|
108
|
-
* 触发关闭事件并通知父组件
|
|
109
|
-
*/
|
|
110
|
-
const onClose = () => {
|
|
111
|
-
resetForm()
|
|
112
|
-
emit('close')
|
|
113
|
-
}
|
|
114
|
-
// 使用 defineExpose 暴露方法
|
|
115
|
-
defineExpose({ init })
|
|
116
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<a-drawer
|
|
3
|
+
:title="editTitle"
|
|
4
|
+
:width="540"
|
|
5
|
+
:open="open"
|
|
6
|
+
:body-style="{ paddingBottom: '80px' }"
|
|
7
|
+
:footer-style="{ textAlign: 'right' }"
|
|
8
|
+
@close="onClose"
|
|
9
|
+
:destroyOnClose="true"
|
|
10
|
+
>
|
|
11
|
+
<a-form :model="formInfo" ref="formRef" layout="vertical">
|
|
12
|
+
<a-form-item
|
|
13
|
+
label="字典名称"
|
|
14
|
+
name="name"
|
|
15
|
+
:rules="[{ required: true, message: '字典名称不能为空' }]"
|
|
16
|
+
>
|
|
17
|
+
<a-input v-model:value="formInfo.name" placeholder="请输入" />
|
|
18
|
+
</a-form-item>
|
|
19
|
+
<a-form-item
|
|
20
|
+
label="字典类型"
|
|
21
|
+
name="type"
|
|
22
|
+
:rules="[{ required: true, message: '字典类型不能为空' }]"
|
|
23
|
+
>
|
|
24
|
+
<a-input v-model:value="formInfo.type" placeholder="请输入" />
|
|
25
|
+
</a-form-item>
|
|
26
|
+
<a-form-item label="是否启用" name="isEnable">
|
|
27
|
+
<a-switch v-model:checked="formInfo.isEnable" />
|
|
28
|
+
</a-form-item>
|
|
29
|
+
<a-form-item label="备注" name="remark">
|
|
30
|
+
<a-textarea v-model:value="formInfo.remark" />
|
|
31
|
+
</a-form-item>
|
|
32
|
+
</a-form>
|
|
33
|
+
<template #extra>
|
|
34
|
+
<a-space>
|
|
35
|
+
<a-button type="primary" @click="onSave" :loading="loading"
|
|
36
|
+
>保存</a-button
|
|
37
|
+
>
|
|
38
|
+
<a-button @click="resetForm">重置</a-button>
|
|
39
|
+
</a-space>
|
|
40
|
+
</template>
|
|
41
|
+
</a-drawer>
|
|
42
|
+
</template>
|
|
43
|
+
<script setup>
|
|
44
|
+
import { defineProps, defineEmits, ref, reactive } from 'vue'
|
|
45
|
+
import { message } from 'ant-design-vue'
|
|
46
|
+
import sysDict from '@/api/methods/sysDict'
|
|
47
|
+
import useFormCRUD from '@/utils/useFormCRUD'
|
|
48
|
+
const props = defineProps({
|
|
49
|
+
open: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
required: true,
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
const defaultformInfo = {
|
|
55
|
+
id: null,
|
|
56
|
+
name: '',
|
|
57
|
+
type: '',
|
|
58
|
+
isEnable: true,
|
|
59
|
+
remark: '',
|
|
60
|
+
}
|
|
61
|
+
// 使用 reactive 定义表单状态
|
|
62
|
+
const formInfo = reactive({ ...defaultformInfo })
|
|
63
|
+
const editTitle = ref('新增')
|
|
64
|
+
const formRef = ref(null)
|
|
65
|
+
// 定义 emits,用于触发关闭事件
|
|
66
|
+
const emit = defineEmits(['close', 'updateData'])
|
|
67
|
+
/**
|
|
68
|
+
* 重置表单到默认值
|
|
69
|
+
*/
|
|
70
|
+
const resetForm = () => {
|
|
71
|
+
Object.assign(formInfo, defaultformInfo)
|
|
72
|
+
formRef.value?.resetFields()
|
|
73
|
+
}
|
|
74
|
+
const { loading, save } = useFormCRUD(sysDict)
|
|
75
|
+
/**
|
|
76
|
+
* 初始化角色编辑表单
|
|
77
|
+
* @param {number} id - 角色ID,如果为0或空则表示新增角色
|
|
78
|
+
*/
|
|
79
|
+
const init = async id => {
|
|
80
|
+
const isEdit = !!id
|
|
81
|
+
editTitle.value = isEdit ? '修改' : '新增'
|
|
82
|
+
|
|
83
|
+
if (isEdit) {
|
|
84
|
+
try {
|
|
85
|
+
const res = await sysDict.get({ id })
|
|
86
|
+
Object.assign(formInfo, res.data)
|
|
87
|
+
} catch (error) {
|
|
88
|
+
message.error('获取信息失败,请重试')
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
resetForm()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 保存
|
|
96
|
+
* 处理表单验证和角色新增/修改操作
|
|
97
|
+
*/
|
|
98
|
+
const onSave = async () => {
|
|
99
|
+
await save(formRef.value, formInfo, {
|
|
100
|
+
onSuccess: () => {
|
|
101
|
+
emit('updateData')
|
|
102
|
+
onClose()
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 关闭抽屉组件
|
|
108
|
+
* 触发关闭事件并通知父组件
|
|
109
|
+
*/
|
|
110
|
+
const onClose = () => {
|
|
111
|
+
resetForm()
|
|
112
|
+
emit('close')
|
|
113
|
+
}
|
|
114
|
+
// 使用 defineExpose 暴露方法
|
|
115
|
+
defineExpose({ init })
|
|
116
|
+
</script>
|