zant-admin 1.0.4 → 2.0.1

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 (94) hide show
  1. package/README.en.md +414 -25
  2. package/README.md +460 -285
  3. package/bin/cli.js +3 -3
  4. package/bin/generator.js +502 -502
  5. package/bin/prompts.js +158 -158
  6. package/bin/utils.js +133 -133
  7. package/package.json +2 -2
  8. package/public/logo.png +0 -0
  9. package/src/App.vue +16 -16
  10. package/src/api/methods/department.js +36 -0
  11. package/src/api/methods/employee.js +22 -0
  12. package/src/api/methods/logError.js +8 -8
  13. package/src/api/methods/logOperation.js +8 -8
  14. package/src/api/methods/login.js +6 -6
  15. package/src/api/methods/position.js +26 -0
  16. package/src/api/methods/quartz.js +36 -36
  17. package/src/api/methods/region.js +16 -16
  18. package/src/api/methods/sysAccount.js +29 -29
  19. package/src/api/methods/sysDict.js +29 -29
  20. package/src/api/methods/sysDictItem.js +26 -26
  21. package/src/api/methods/sysMenu.js +42 -42
  22. package/src/api/methods/sysRole.js +35 -35
  23. package/src/api/methods/sysUser.js +25 -25
  24. package/src/api/methods/system.js +15 -15
  25. package/src/api/request.js +225 -225
  26. package/src/assets/css/style.css +2 -2
  27. package/src/assets/css/zcui.css +1023 -1023
  28. package/src/assets/imgs/logo.png +0 -0
  29. package/src/assets/imgs/md/console.png +0 -0
  30. package/src/assets/imgs/md/login.png +0 -0
  31. package/src/assets/imgs/md/menu.png +0 -0
  32. package/src/assets/imgs/md/serviceMonitoring.png +0 -0
  33. package/src/assets/imgs/md/statistics.png +0 -0
  34. package/src/components/FormTable.vue +5 -19
  35. package/src/components/IconPicker.vue +351 -351
  36. package/src/components/MainPage.vue +838 -838
  37. package/src/components/details/logErrorDetails.vue +58 -58
  38. package/src/components/details/logOperationDetails.vue +76 -76
  39. package/src/components/edit/QuartzEdit.vue +221 -221
  40. package/src/components/edit/SysAccountEdit.vue +185 -185
  41. package/src/components/edit/SysDictEdit.vue +116 -116
  42. package/src/components/edit/SysDictItemEdit.vue +136 -136
  43. package/src/components/edit/SysRoleEdit.vue +111 -111
  44. package/src/components/edit/organizationalStructure/DepartmentEdit.vue +162 -0
  45. package/src/components/edit/organizationalStructure/EmployeeEdit.vue +295 -0
  46. package/src/components/edit/organizationalStructure/PositionEdit.vue +166 -0
  47. package/src/components/edit/sysMenuEdit.vue +2 -1
  48. package/src/config/index.js +74 -74
  49. package/src/directives/permission.js +49 -49
  50. package/src/main.js +37 -37
  51. package/src/router/index.js +4 -6
  52. package/src/stores/config.js +43 -43
  53. package/src/stores/dict.js +33 -33
  54. package/src/stores/menu.js +81 -81
  55. package/src/stores/user.js +21 -21
  56. package/src/utils/baseEcharts.js +661 -661
  57. package/src/utils/dictTemplate.js +26 -26
  58. package/src/utils/regionUtils.js +173 -173
  59. package/src/utils/useFormCRUD.js +59 -59
  60. package/src/views/baiscstatis/center.vue +474 -474
  61. package/src/views/baiscstatis/iframePage.vue +29 -29
  62. package/src/views/baiscstatis/notFound.vue +192 -192
  63. package/src/views/console.vue +821 -821
  64. package/src/views/demo/button.vue +269 -269
  65. package/src/views/demo/importexport.vue +119 -119
  66. package/src/views/demo/region.vue +322 -322
  67. package/src/views/demo/statistics.vue +214 -214
  68. package/src/views/home.vue +6 -6
  69. package/src/views/login.vue +264 -149
  70. package/src/views/operations/log/logError.vue +78 -78
  71. package/src/views/operations/log/logLogin.vue +66 -66
  72. package/src/views/operations/log/logOperation.vue +103 -103
  73. package/src/views/operations/log/logQuartz.vue +56 -56
  74. package/src/views/operations/quartz.vue +179 -179
  75. package/src/views/operations/serviceMonitoring.vue +134 -134
  76. package/src/views/organizationalStructure/department.vue +194 -0
  77. package/src/views/organizationalStructure/employee.vue +234 -0
  78. package/src/views/organizationalStructure/position.vue +196 -0
  79. package/src/views/system/sysAccount.vue +128 -128
  80. package/src/views/system/sysDict.vue +159 -159
  81. package/src/views/system/sysDictItem.vue +118 -118
  82. package/src/views/system/sysMenu.vue +225 -225
  83. package/src/views/system/sysRole.vue +207 -207
  84. package/src/assets/imgs/md/1.png +0 -0
  85. package/src/assets/imgs/md/10.png +0 -0
  86. package/src/assets/imgs/md/11.png +0 -0
  87. package/src/assets/imgs/md/2.png +0 -0
  88. package/src/assets/imgs/md/3.png +0 -0
  89. package/src/assets/imgs/md/4.png +0 -0
  90. package/src/assets/imgs/md/5.png +0 -0
  91. package/src/assets/imgs/md/6.png +0 -0
  92. package/src/assets/imgs/md/7.png +0 -0
  93. package/src/assets/imgs/md/8.png +0 -0
  94. package/src/assets/imgs/md/9.png +0 -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>
@@ -0,0 +1,162 @@
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-skeleton :loading="initloading" active>
12
+
13
+ <a-form :model="formInfo" ref="formRef" layout="vertical" >
14
+ <a-form-item label="上级组织" name="parentId">
15
+ <a-tree-select
16
+ v-model:value="formInfo.parentId"
17
+ show-search
18
+ style="width: 100%"
19
+ :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
20
+ placeholder="请选择"
21
+ allow-clear
22
+ tree-default-expand-all
23
+ :tree-data="orgTree"
24
+ tree-node-filter-prop="label"
25
+
26
+ />
27
+ </a-form-item>
28
+ <a-form-item label="组织名称" name="name" :rules="[{ required: true, message: '请输入组织名称' }]">
29
+ <a-input v-model:value="formInfo.name" placeholder="请输入" />
30
+ </a-form-item>
31
+
32
+ <a-form-item label="组织类型" name="orgType">
33
+ <a-select
34
+ v-model:value="formInfo.orgType"
35
+ placeholder="请选择"
36
+ :options="orgTypeOptions"
37
+ />
38
+ </a-form-item>
39
+
40
+
41
+ <a-form-item label="排序序号" name="sort">
42
+ <a-input-number
43
+ v-model:value="formInfo.sort"
44
+ :min="0"
45
+ style="width: 100%"
46
+ placeholder="请输入"
47
+ />
48
+ </a-form-item>
49
+ <a-form-item label="是否启用" name="isEnable">
50
+ <a-switch v-model:checked="formInfo.isEnable" />
51
+ </a-form-item>
52
+ </a-form>
53
+ </a-skeleton>
54
+ <template #extra>
55
+ <a-space>
56
+ <a-button type="primary" @click="onSave" :loading="loading">保存</a-button>
57
+ <a-button @click="resetForm">重置</a-button>
58
+ </a-space>
59
+ </template>
60
+ </a-drawer>
61
+ </template>
62
+ <script setup>
63
+ import { defineProps, defineEmits, ref, reactive } from 'vue'
64
+ import { message } from 'ant-design-vue'
65
+ import department from '@/api/methods/department'
66
+ import useFormCRUD from '@/utils/useFormCRUD'
67
+
68
+ const props = defineProps({
69
+ open: {
70
+ type: Boolean,
71
+ required: true,
72
+ },
73
+ })
74
+
75
+ const orgTypeOptions = [
76
+ { label: '公司', value: 1 },
77
+ { label: '部门', value: 2 },
78
+ { label: '小组', value: 3 },
79
+ { label: '虚拟团队', value: 4 },
80
+ ]
81
+
82
+ const defaultformInfo = {
83
+ id: null,
84
+ parentId: "0",
85
+ ancestors: '',
86
+ name: '',
87
+ orgType: 1,
88
+ sort: 0,
89
+ isEnable: true,
90
+ }
91
+
92
+ const formInfo = reactive({ ...defaultformInfo })
93
+ const editTitle = ref('新增')
94
+ const formRef = ref(null)
95
+ const orgTree = ref([])
96
+ const emit = defineEmits(['close', 'updateData'])
97
+ const { loading, save } = useFormCRUD(department)
98
+
99
+ const resetForm = () => {
100
+ Object.assign(formInfo, defaultformInfo)
101
+ formRef.value?.resetFields()
102
+ }
103
+
104
+ const initloading = ref(false)
105
+
106
+ const init = async id => {
107
+ initloading.value = true
108
+ const isEdit = !!id
109
+ editTitle.value = isEdit ? '修改' : '新增'
110
+
111
+ if (isEdit) {
112
+ try {
113
+ const res = await department.get({ id })
114
+ initloading.value = false
115
+ Object.assign(formInfo, res.data)
116
+ } catch (error) {
117
+ message.error('获取信息失败,请重试')
118
+ initloading.value = false
119
+ }
120
+ } else {
121
+ initloading.value = false
122
+ resetForm()
123
+ }
124
+ }
125
+
126
+ const onSave = async () => {
127
+ await save(formRef.value, formInfo, {
128
+ onSuccess: () => {
129
+ emit('updateData')
130
+ onClose()
131
+ },
132
+ })
133
+ }
134
+
135
+ const onClose = () => {
136
+ resetForm()
137
+ emit('close')
138
+ }
139
+ ///获取组织树
140
+ const getOrgTree = async () => {
141
+ try {
142
+ const res = await department.getTreeSelectdepartment()
143
+ orgTree.value = res.data
144
+ } catch (error) {}
145
+ }
146
+
147
+ // 添加下级
148
+ const addSubOrg = record => {
149
+ editTitle.value = '新增下级'
150
+ resetForm()
151
+ formInfo.id = null
152
+ formInfo.parentId = record.id
153
+ formInfo.ancestors = record.ancestors
154
+ formInfo.sort = record.sort
155
+ }
156
+
157
+ defineExpose({
158
+ init,
159
+ getOrgTree,
160
+ addSubOrg
161
+ })
162
+ </script>