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,136 +1,136 @@
|
|
|
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="label"
|
|
15
|
-
:rules="[{ required: true, message: '字典标签不能为空' }]"
|
|
16
|
-
>
|
|
17
|
-
<a-input
|
|
18
|
-
:class="formInfo.colorClass"
|
|
19
|
-
v-model:value="formInfo.label"
|
|
20
|
-
placeholder="请输入"
|
|
21
|
-
/>
|
|
22
|
-
</a-form-item>
|
|
23
|
-
<a-form-item label="字典值" name="value">
|
|
24
|
-
<a-input-number v-model:value="formInfo.value" placeholder="请输入" />
|
|
25
|
-
</a-form-item>
|
|
26
|
-
<a-form-item label="颜色样式" name="colorClass">
|
|
27
|
-
<a-select v-model:value="formInfo.colorClass" @change="selectColor">
|
|
28
|
-
<a-select-option value="default">default</a-select-option>
|
|
29
|
-
<a-select-option value="text-color-primary">primary</a-select-option>
|
|
30
|
-
<a-select-option value="text-color-success">success</a-select-option>
|
|
31
|
-
<a-select-option value="text-color-warning">warning</a-select-option>
|
|
32
|
-
<a-select-option value="text-color-error">error</a-select-option>
|
|
33
|
-
<a-select-option value="text-color-gray">gray</a-select-option>
|
|
34
|
-
<a-select-option value="text-color-textgray"
|
|
35
|
-
>textgray</a-select-option
|
|
36
|
-
>
|
|
37
|
-
</a-select>
|
|
38
|
-
</a-form-item>
|
|
39
|
-
<a-form-item label="排序" name="sort">
|
|
40
|
-
<a-input-number v-model:value="formInfo.sort" placeholder="请输入" />
|
|
41
|
-
</a-form-item>
|
|
42
|
-
<a-form-item label="是否启用" name="isEnable">
|
|
43
|
-
<a-switch v-model:checked="formInfo.isEnable" />
|
|
44
|
-
</a-form-item>
|
|
45
|
-
<a-form-item label="备注" name="remark">
|
|
46
|
-
<a-textarea v-model:value="formInfo.remark" />
|
|
47
|
-
</a-form-item>
|
|
48
|
-
</a-form>
|
|
49
|
-
<template #extra>
|
|
50
|
-
<a-space>
|
|
51
|
-
<a-button type="primary" @click="onSave" :loading="loading"
|
|
52
|
-
>保存</a-button
|
|
53
|
-
>
|
|
54
|
-
<a-button @click="resetForm">重置</a-button>
|
|
55
|
-
</a-space>
|
|
56
|
-
</template>
|
|
57
|
-
</a-drawer>
|
|
58
|
-
</template>
|
|
59
|
-
<script setup>
|
|
60
|
-
import { defineProps, defineEmits, ref, reactive } from 'vue'
|
|
61
|
-
import { message } from 'ant-design-vue'
|
|
62
|
-
import sysDictItem from '@/api/methods/sysDictItem'
|
|
63
|
-
import useFormCRUD from '@/utils/useFormCRUD'
|
|
64
|
-
const props = defineProps({
|
|
65
|
-
open: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
required: true,
|
|
68
|
-
},
|
|
69
|
-
recordwhere: {
|
|
70
|
-
type: Object,
|
|
71
|
-
default: {},
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
const defaultformInfo = {
|
|
75
|
-
id: null,
|
|
76
|
-
dictId: props.recordwhere.dictId,
|
|
77
|
-
label: '',
|
|
78
|
-
colorClass: 'default',
|
|
79
|
-
value: 0,
|
|
80
|
-
sort: 0,
|
|
81
|
-
isEnable: true,
|
|
82
|
-
remark: '',
|
|
83
|
-
}
|
|
84
|
-
// 使用 reactive 定义表单状态
|
|
85
|
-
const formInfo = reactive({ ...defaultformInfo })
|
|
86
|
-
const editTitle = ref('新增')
|
|
87
|
-
const formRef = ref(null)
|
|
88
|
-
// 定义 emits,用于触发关闭事件
|
|
89
|
-
const emit = defineEmits(['close', 'updateData'])
|
|
90
|
-
/**
|
|
91
|
-
* 重置表单到默认值
|
|
92
|
-
*/
|
|
93
|
-
const resetForm = () => {
|
|
94
|
-
Object.assign(formInfo, defaultformInfo)
|
|
95
|
-
formRef.value?.resetFields()
|
|
96
|
-
}
|
|
97
|
-
const { loading, save } = useFormCRUD(sysDictItem)
|
|
98
|
-
|
|
99
|
-
const init = async id => {
|
|
100
|
-
const isEdit = !!id
|
|
101
|
-
editTitle.value = isEdit ? '修改' : '新增'
|
|
102
|
-
if (isEdit) {
|
|
103
|
-
try {
|
|
104
|
-
const res = await sysDictItem.get({ id })
|
|
105
|
-
Object.assign(formInfo, res.data)
|
|
106
|
-
} catch (error) {
|
|
107
|
-
message.error('获取信息失败,请重试')
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
console.log('ss' + props.recordwhere)
|
|
111
|
-
resetForm()
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const onSave = async () => {
|
|
116
|
-
await save(formRef.value, formInfo, {
|
|
117
|
-
onSuccess: () => {
|
|
118
|
-
emit('updateData')
|
|
119
|
-
onClose()
|
|
120
|
-
},
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const selectColor = e => {
|
|
125
|
-
console.log(e)
|
|
126
|
-
formInfo.colorClass = e
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const onClose = () => {
|
|
130
|
-
emit('close')
|
|
131
|
-
}
|
|
132
|
-
// 使用 defineExpose 暴露方法
|
|
133
|
-
defineExpose({
|
|
134
|
-
init,
|
|
135
|
-
})
|
|
136
|
-
</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="label"
|
|
15
|
+
:rules="[{ required: true, message: '字典标签不能为空' }]"
|
|
16
|
+
>
|
|
17
|
+
<a-input
|
|
18
|
+
:class="formInfo.colorClass"
|
|
19
|
+
v-model:value="formInfo.label"
|
|
20
|
+
placeholder="请输入"
|
|
21
|
+
/>
|
|
22
|
+
</a-form-item>
|
|
23
|
+
<a-form-item label="字典值" name="value">
|
|
24
|
+
<a-input-number v-model:value="formInfo.value" placeholder="请输入" />
|
|
25
|
+
</a-form-item>
|
|
26
|
+
<a-form-item label="颜色样式" name="colorClass">
|
|
27
|
+
<a-select v-model:value="formInfo.colorClass" @change="selectColor">
|
|
28
|
+
<a-select-option value="default">default</a-select-option>
|
|
29
|
+
<a-select-option value="text-color-primary">primary</a-select-option>
|
|
30
|
+
<a-select-option value="text-color-success">success</a-select-option>
|
|
31
|
+
<a-select-option value="text-color-warning">warning</a-select-option>
|
|
32
|
+
<a-select-option value="text-color-error">error</a-select-option>
|
|
33
|
+
<a-select-option value="text-color-gray">gray</a-select-option>
|
|
34
|
+
<a-select-option value="text-color-textgray"
|
|
35
|
+
>textgray</a-select-option
|
|
36
|
+
>
|
|
37
|
+
</a-select>
|
|
38
|
+
</a-form-item>
|
|
39
|
+
<a-form-item label="排序" name="sort">
|
|
40
|
+
<a-input-number v-model:value="formInfo.sort" placeholder="请输入" />
|
|
41
|
+
</a-form-item>
|
|
42
|
+
<a-form-item label="是否启用" name="isEnable">
|
|
43
|
+
<a-switch v-model:checked="formInfo.isEnable" />
|
|
44
|
+
</a-form-item>
|
|
45
|
+
<a-form-item label="备注" name="remark">
|
|
46
|
+
<a-textarea v-model:value="formInfo.remark" />
|
|
47
|
+
</a-form-item>
|
|
48
|
+
</a-form>
|
|
49
|
+
<template #extra>
|
|
50
|
+
<a-space>
|
|
51
|
+
<a-button type="primary" @click="onSave" :loading="loading"
|
|
52
|
+
>保存</a-button
|
|
53
|
+
>
|
|
54
|
+
<a-button @click="resetForm">重置</a-button>
|
|
55
|
+
</a-space>
|
|
56
|
+
</template>
|
|
57
|
+
</a-drawer>
|
|
58
|
+
</template>
|
|
59
|
+
<script setup>
|
|
60
|
+
import { defineProps, defineEmits, ref, reactive } from 'vue'
|
|
61
|
+
import { message } from 'ant-design-vue'
|
|
62
|
+
import sysDictItem from '@/api/methods/sysDictItem'
|
|
63
|
+
import useFormCRUD from '@/utils/useFormCRUD'
|
|
64
|
+
const props = defineProps({
|
|
65
|
+
open: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
recordwhere: {
|
|
70
|
+
type: Object,
|
|
71
|
+
default: {},
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
const defaultformInfo = {
|
|
75
|
+
id: null,
|
|
76
|
+
dictId: props.recordwhere.dictId,
|
|
77
|
+
label: '',
|
|
78
|
+
colorClass: 'default',
|
|
79
|
+
value: 0,
|
|
80
|
+
sort: 0,
|
|
81
|
+
isEnable: true,
|
|
82
|
+
remark: '',
|
|
83
|
+
}
|
|
84
|
+
// 使用 reactive 定义表单状态
|
|
85
|
+
const formInfo = reactive({ ...defaultformInfo })
|
|
86
|
+
const editTitle = ref('新增')
|
|
87
|
+
const formRef = ref(null)
|
|
88
|
+
// 定义 emits,用于触发关闭事件
|
|
89
|
+
const emit = defineEmits(['close', 'updateData'])
|
|
90
|
+
/**
|
|
91
|
+
* 重置表单到默认值
|
|
92
|
+
*/
|
|
93
|
+
const resetForm = () => {
|
|
94
|
+
Object.assign(formInfo, defaultformInfo)
|
|
95
|
+
formRef.value?.resetFields()
|
|
96
|
+
}
|
|
97
|
+
const { loading, save } = useFormCRUD(sysDictItem)
|
|
98
|
+
|
|
99
|
+
const init = async id => {
|
|
100
|
+
const isEdit = !!id
|
|
101
|
+
editTitle.value = isEdit ? '修改' : '新增'
|
|
102
|
+
if (isEdit) {
|
|
103
|
+
try {
|
|
104
|
+
const res = await sysDictItem.get({ id })
|
|
105
|
+
Object.assign(formInfo, res.data)
|
|
106
|
+
} catch (error) {
|
|
107
|
+
message.error('获取信息失败,请重试')
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
console.log('ss' + props.recordwhere)
|
|
111
|
+
resetForm()
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const onSave = async () => {
|
|
116
|
+
await save(formRef.value, formInfo, {
|
|
117
|
+
onSuccess: () => {
|
|
118
|
+
emit('updateData')
|
|
119
|
+
onClose()
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const selectColor = e => {
|
|
125
|
+
console.log(e)
|
|
126
|
+
formInfo.colorClass = e
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const onClose = () => {
|
|
130
|
+
emit('close')
|
|
131
|
+
}
|
|
132
|
+
// 使用 defineExpose 暴露方法
|
|
133
|
+
defineExpose({
|
|
134
|
+
init,
|
|
135
|
+
})
|
|
136
|
+
</script>
|
|
@@ -1,111 +1,111 @@
|
|
|
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 label="是否启用" name="isEnable">
|
|
20
|
-
<a-switch v-model:checked="formInfo.isEnable" />
|
|
21
|
-
</a-form-item>
|
|
22
|
-
<a-form-item label="备注" name="remark">
|
|
23
|
-
<a-textarea v-model:value="formInfo.remark" />
|
|
24
|
-
</a-form-item>
|
|
25
|
-
</a-form>
|
|
26
|
-
<template #extra>
|
|
27
|
-
<a-space>
|
|
28
|
-
<a-button type="primary" @click="onSave" :loading="loading"
|
|
29
|
-
>保存</a-button
|
|
30
|
-
>
|
|
31
|
-
<a-button @click="resetForm">重置</a-button>
|
|
32
|
-
</a-space>
|
|
33
|
-
</template>
|
|
34
|
-
</a-drawer>
|
|
35
|
-
</template>
|
|
36
|
-
<script setup>
|
|
37
|
-
import { defineProps, defineEmits, ref, reactive } from 'vue'
|
|
38
|
-
import { message } from 'ant-design-vue'
|
|
39
|
-
import sysRole from '@/api/methods/sysRole'
|
|
40
|
-
import useFormCRUD from '@/utils/useFormCRUD'
|
|
41
|
-
const props = defineProps({
|
|
42
|
-
open: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
required: true,
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
// 表单字段的默认值
|
|
48
|
-
const defaultformInfo = {
|
|
49
|
-
id: null,
|
|
50
|
-
name: '',
|
|
51
|
-
isEnable: true,
|
|
52
|
-
remark: '',
|
|
53
|
-
}
|
|
54
|
-
// 响应式数据
|
|
55
|
-
const formInfo = reactive({ ...defaultformInfo })
|
|
56
|
-
const editTitle = ref('新增')
|
|
57
|
-
const formRef = ref(null)
|
|
58
|
-
// 定义 emits,用于触发关闭事件
|
|
59
|
-
const emit = defineEmits(['close', 'updateData'])
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 重置表单到默认值
|
|
63
|
-
*/
|
|
64
|
-
const resetForm = () => {
|
|
65
|
-
Object.assign(formInfo, defaultformInfo)
|
|
66
|
-
formRef.value?.resetFields()
|
|
67
|
-
}
|
|
68
|
-
const { loading, save } = useFormCRUD(sysRole)
|
|
69
|
-
/**
|
|
70
|
-
* 初始化角色编辑表单
|
|
71
|
-
* @param {number} id - 角色ID,如果为0或空则表示新增角色
|
|
72
|
-
*/
|
|
73
|
-
const init = async id => {
|
|
74
|
-
const isEdit = !!id
|
|
75
|
-
editTitle.value = isEdit ? '修改' : '新增'
|
|
76
|
-
|
|
77
|
-
if (isEdit) {
|
|
78
|
-
try {
|
|
79
|
-
const res = await sysRole.get({ id })
|
|
80
|
-
Object.assign(formInfo, res.data)
|
|
81
|
-
} catch (error) {
|
|
82
|
-
message.error('获取信息失败,请重试')
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
resetForm()
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 保存角色信息
|
|
91
|
-
* 处理表单验证和角色新增/修改操作
|
|
92
|
-
*/
|
|
93
|
-
const onSave = async () => {
|
|
94
|
-
await save(formRef.value, formInfo, {
|
|
95
|
-
onSuccess: () => {
|
|
96
|
-
emit('updateData')
|
|
97
|
-
onClose()
|
|
98
|
-
},
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* 关闭抽屉组件
|
|
103
|
-
* 触发关闭事件并通知父组件
|
|
104
|
-
*/
|
|
105
|
-
const onClose = () => {
|
|
106
|
-
resetForm()
|
|
107
|
-
emit('close')
|
|
108
|
-
}
|
|
109
|
-
// 使用 defineExpose 暴露方法
|
|
110
|
-
defineExpose({ init })
|
|
111
|
-
</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 label="是否启用" name="isEnable">
|
|
20
|
+
<a-switch v-model:checked="formInfo.isEnable" />
|
|
21
|
+
</a-form-item>
|
|
22
|
+
<a-form-item label="备注" name="remark">
|
|
23
|
+
<a-textarea v-model:value="formInfo.remark" />
|
|
24
|
+
</a-form-item>
|
|
25
|
+
</a-form>
|
|
26
|
+
<template #extra>
|
|
27
|
+
<a-space>
|
|
28
|
+
<a-button type="primary" @click="onSave" :loading="loading"
|
|
29
|
+
>保存</a-button
|
|
30
|
+
>
|
|
31
|
+
<a-button @click="resetForm">重置</a-button>
|
|
32
|
+
</a-space>
|
|
33
|
+
</template>
|
|
34
|
+
</a-drawer>
|
|
35
|
+
</template>
|
|
36
|
+
<script setup>
|
|
37
|
+
import { defineProps, defineEmits, ref, reactive } from 'vue'
|
|
38
|
+
import { message } from 'ant-design-vue'
|
|
39
|
+
import sysRole from '@/api/methods/sysRole'
|
|
40
|
+
import useFormCRUD from '@/utils/useFormCRUD'
|
|
41
|
+
const props = defineProps({
|
|
42
|
+
open: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
// 表单字段的默认值
|
|
48
|
+
const defaultformInfo = {
|
|
49
|
+
id: null,
|
|
50
|
+
name: '',
|
|
51
|
+
isEnable: true,
|
|
52
|
+
remark: '',
|
|
53
|
+
}
|
|
54
|
+
// 响应式数据
|
|
55
|
+
const formInfo = reactive({ ...defaultformInfo })
|
|
56
|
+
const editTitle = ref('新增')
|
|
57
|
+
const formRef = ref(null)
|
|
58
|
+
// 定义 emits,用于触发关闭事件
|
|
59
|
+
const emit = defineEmits(['close', 'updateData'])
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 重置表单到默认值
|
|
63
|
+
*/
|
|
64
|
+
const resetForm = () => {
|
|
65
|
+
Object.assign(formInfo, defaultformInfo)
|
|
66
|
+
formRef.value?.resetFields()
|
|
67
|
+
}
|
|
68
|
+
const { loading, save } = useFormCRUD(sysRole)
|
|
69
|
+
/**
|
|
70
|
+
* 初始化角色编辑表单
|
|
71
|
+
* @param {number} id - 角色ID,如果为0或空则表示新增角色
|
|
72
|
+
*/
|
|
73
|
+
const init = async id => {
|
|
74
|
+
const isEdit = !!id
|
|
75
|
+
editTitle.value = isEdit ? '修改' : '新增'
|
|
76
|
+
|
|
77
|
+
if (isEdit) {
|
|
78
|
+
try {
|
|
79
|
+
const res = await sysRole.get({ id })
|
|
80
|
+
Object.assign(formInfo, res.data)
|
|
81
|
+
} catch (error) {
|
|
82
|
+
message.error('获取信息失败,请重试')
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
resetForm()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 保存角色信息
|
|
91
|
+
* 处理表单验证和角色新增/修改操作
|
|
92
|
+
*/
|
|
93
|
+
const onSave = async () => {
|
|
94
|
+
await save(formRef.value, formInfo, {
|
|
95
|
+
onSuccess: () => {
|
|
96
|
+
emit('updateData')
|
|
97
|
+
onClose()
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 关闭抽屉组件
|
|
103
|
+
* 触发关闭事件并通知父组件
|
|
104
|
+
*/
|
|
105
|
+
const onClose = () => {
|
|
106
|
+
resetForm()
|
|
107
|
+
emit('close')
|
|
108
|
+
}
|
|
109
|
+
// 使用 defineExpose 暴露方法
|
|
110
|
+
defineExpose({ init })
|
|
111
|
+
</script>
|
package/src/config/index.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 全局配置文件
|
|
3
|
-
* 用于定义项目的全局配置信息
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// 项目基本信息
|
|
7
|
-
export const projectConfig = {
|
|
8
|
-
// 项目名称
|
|
9
|
-
name: 'ZAntAdmin',
|
|
10
|
-
// 项目版本
|
|
11
|
-
version: '1.0.0',
|
|
12
|
-
// 项目描述
|
|
13
|
-
description: '基于 Vue 3.5 + Ant Design Vue 的管理系统',
|
|
14
|
-
// 项目作者
|
|
15
|
-
author: 'ZC',
|
|
16
|
-
// 项目主页
|
|
17
|
-
homepage: '',
|
|
18
|
-
// 项目仓库
|
|
19
|
-
repository: '',
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// API 配置
|
|
23
|
-
export const apiConfig = {
|
|
24
|
-
// API 基础路径
|
|
25
|
-
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
|
|
26
|
-
// 请求超时时间
|
|
27
|
-
timeout: 10000,
|
|
28
|
-
// 请求头
|
|
29
|
-
headers: {
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 应用配置
|
|
35
|
-
export const appConfig = {
|
|
36
|
-
// 应用标题
|
|
37
|
-
title: projectConfig.name,
|
|
38
|
-
// 应用图标
|
|
39
|
-
icon: '/logo.png',
|
|
40
|
-
// 默认语言
|
|
41
|
-
defaultLanguage: 'zh-cn',
|
|
42
|
-
// 默认主题
|
|
43
|
-
defaultTheme: 'dark',
|
|
44
|
-
// 默认导航模式
|
|
45
|
-
defaultNavigationMode: 'side',
|
|
46
|
-
// 默认表格大小
|
|
47
|
-
defaultTableSize: 'middle',
|
|
48
|
-
// 默认表格边框
|
|
49
|
-
defaultTableBordered: true,
|
|
50
|
-
// 是否显示页脚
|
|
51
|
-
showFooter: true,
|
|
52
|
-
// 页脚文本
|
|
53
|
-
footerText: `© ${new Date().getFullYear()} ${projectConfig.name}`,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 路由配置
|
|
57
|
-
export const routerConfig = {
|
|
58
|
-
// 首页路径
|
|
59
|
-
homePath: '/console',
|
|
60
|
-
// 登录页路径
|
|
61
|
-
loginPath: '/login',
|
|
62
|
-
// 404 页面路径
|
|
63
|
-
notFoundPath: '/404',
|
|
64
|
-
// 是否开启路由守卫
|
|
65
|
-
guard: true,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 默认导出所有配置
|
|
69
|
-
export default {
|
|
70
|
-
project: projectConfig,
|
|
71
|
-
api: apiConfig,
|
|
72
|
-
app: appConfig,
|
|
73
|
-
router: routerConfig,
|
|
74
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 全局配置文件
|
|
3
|
+
* 用于定义项目的全局配置信息
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// 项目基本信息
|
|
7
|
+
export const projectConfig = {
|
|
8
|
+
// 项目名称
|
|
9
|
+
name: 'ZAntAdmin',
|
|
10
|
+
// 项目版本
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
// 项目描述
|
|
13
|
+
description: '基于 Vue 3.5 + Ant Design Vue 的管理系统',
|
|
14
|
+
// 项目作者
|
|
15
|
+
author: 'ZC',
|
|
16
|
+
// 项目主页
|
|
17
|
+
homepage: '',
|
|
18
|
+
// 项目仓库
|
|
19
|
+
repository: '',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// API 配置
|
|
23
|
+
export const apiConfig = {
|
|
24
|
+
// API 基础路径
|
|
25
|
+
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
|
|
26
|
+
// 请求超时时间
|
|
27
|
+
timeout: 10000,
|
|
28
|
+
// 请求头
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 应用配置
|
|
35
|
+
export const appConfig = {
|
|
36
|
+
// 应用标题
|
|
37
|
+
title: projectConfig.name,
|
|
38
|
+
// 应用图标
|
|
39
|
+
icon: '/logo.png',
|
|
40
|
+
// 默认语言
|
|
41
|
+
defaultLanguage: 'zh-cn',
|
|
42
|
+
// 默认主题
|
|
43
|
+
defaultTheme: 'dark',
|
|
44
|
+
// 默认导航模式
|
|
45
|
+
defaultNavigationMode: 'side',
|
|
46
|
+
// 默认表格大小
|
|
47
|
+
defaultTableSize: 'middle',
|
|
48
|
+
// 默认表格边框
|
|
49
|
+
defaultTableBordered: true,
|
|
50
|
+
// 是否显示页脚
|
|
51
|
+
showFooter: true,
|
|
52
|
+
// 页脚文本
|
|
53
|
+
footerText: `© ${new Date().getFullYear()} ${projectConfig.name}`,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 路由配置
|
|
57
|
+
export const routerConfig = {
|
|
58
|
+
// 首页路径
|
|
59
|
+
homePath: '/console',
|
|
60
|
+
// 登录页路径
|
|
61
|
+
loginPath: '/login',
|
|
62
|
+
// 404 页面路径
|
|
63
|
+
notFoundPath: '/404',
|
|
64
|
+
// 是否开启路由守卫
|
|
65
|
+
guard: true,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 默认导出所有配置
|
|
69
|
+
export default {
|
|
70
|
+
project: projectConfig,
|
|
71
|
+
api: apiConfig,
|
|
72
|
+
app: appConfig,
|
|
73
|
+
router: routerConfig,
|
|
74
|
+
}
|