Commit 565024f07697df551f55cc19191a8d958ed24e38
1 parent
f833cb1e
feat(front): 添加组织管理的CRUD及添加用户时的所属组织
Showing
13 changed files
with
147 additions
and
187 deletions
... | ... | @@ -9,7 +9,6 @@ import {ErrorMessageMode} from "/#/axios"; |
9 | 9 | enum Api { |
10 | 10 | DeptList = '/dept/all', |
11 | 11 | basicUrl = '/dept', |
12 | - // CONFIG_ITEM_URL = '/dictItem' | |
13 | 12 | } |
14 | 13 | |
15 | 14 | export const getDeptList = (params?: DeptListItem) => |
... | ... | @@ -19,11 +18,7 @@ export const getDeptList = (params?: DeptListItem) => |
19 | 18 | * @description: save or edit dept api |
20 | 19 | */ |
21 | 20 | export function saveOrEditDeptApi(params: DeptOperationParams, update: boolean = false, mode: ErrorMessageMode = 'modal') { |
22 | - // console.log(params); | |
23 | 21 | if (!update) { |
24 | - // console.log("-------------后台的参数-------------------"); | |
25 | - // console.log(params); | |
26 | - | |
27 | 22 | return defHttp.post<DeptOperationApiResult>( |
28 | 23 | { |
29 | 24 | url: Api.basicUrl, | ... | ... |
... | ... | @@ -2,13 +2,13 @@ import {defHttp} from "/@/utils/http/axios"; |
2 | 2 | import {GroupListResultModel} from "/@/api/system/model/groupModel"; |
3 | 3 | |
4 | 4 | enum GroupApi { |
5 | - BASE_URL="/group" | |
5 | + BASE_URL="/organization" | |
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
9 | - * 查询当前用户的所辖分组 | |
9 | + * 查询当前用户的所属组织 | |
10 | 10 | */ |
11 | 11 | export const findCurrentUserGroups=()=> |
12 | 12 | defHttp.get<GroupListResultModel>({ |
13 | - url: GroupApi.BASE_URL+"/me/groups", | |
13 | + url: GroupApi.BASE_URL+"/me/organizations", | |
14 | 14 | }); | ... | ... |
... | ... | @@ -36,12 +36,11 @@ export interface AccountListItem { |
36 | 36 | accountExpireTime?:string; |
37 | 37 | } |
38 | 38 | |
39 | -export interface DeptListItem { | |
39 | +export interface OrganizationListItem { | |
40 | 40 | id: string; |
41 | - orderNo: string; | |
42 | - createTime: string; | |
41 | + name: string; | |
42 | + parentId?: string; | |
43 | 43 | remark: string; |
44 | - status: number; | |
45 | 44 | } |
46 | 45 | |
47 | 46 | export interface MenuListItem { |
... | ... | @@ -75,13 +74,13 @@ export interface ChangeAccountParams { |
75 | 74 | resetPassword?:string; |
76 | 75 | } |
77 | 76 | |
78 | -export class RoleOrGroupParam{ | |
77 | +export class RoleOrOrganizationParam { | |
79 | 78 | userId:string; |
80 | 79 | queryRole:boolean; |
81 | - queryGroup:boolean; | |
82 | - constructor(userId:string,queryRole:boolean,queryGroup:boolean){ | |
80 | + queryOrganization:boolean; | |
81 | + constructor(userId:string,queryRole:boolean,queryOrganization:boolean){ | |
83 | 82 | this.queryRole = queryRole; |
84 | - this.queryGroup = queryGroup; | |
83 | + this.queryOrganization = queryOrganization; | |
85 | 84 | this.userId = userId; |
86 | 85 | } |
87 | 86 | } |
... | ... | @@ -91,7 +90,7 @@ export class RoleOrGroupParam{ |
91 | 90 | */ |
92 | 91 | export type AccountListGetResultModel = BasicFetchResult<AccountListItem>; |
93 | 92 | |
94 | -export type DeptListGetResultModel = BasicFetchResult<DeptListItem>; | |
93 | +export type OrganizationListGetResultModel = BasicFetchResult<OrganizationListItem>; | |
95 | 94 | |
96 | 95 | export type MenuListGetResultModel = BasicFetchResult<MenuListItem>; |
97 | 96 | ... | ... |
1 | 1 | import { |
2 | 2 | AccountParams, |
3 | - DeptListItem, | |
3 | + OrganizationListItem, | |
4 | 4 | MenuParams, |
5 | 5 | RoleParams, |
6 | 6 | RolePageParams, |
7 | 7 | MenuListGetResultModel, |
8 | - DeptListGetResultModel, | |
8 | + OrganizationListGetResultModel, | |
9 | 9 | AccountListGetResultModel, |
10 | 10 | RolePageListGetResultModel, |
11 | 11 | RoleListGetResultModel, |
12 | 12 | RoleReqDTO, |
13 | 13 | AccountListItem, |
14 | 14 | AccountListModel, |
15 | - RoleOrGroupParam, | |
15 | + RoleOrOrganizationParam, | |
16 | 16 | ChangeAccountParams, |
17 | 17 | } from './model/systemModel'; |
18 | 18 | import {defHttp} from '/@/utils/http/axios'; |
... | ... | @@ -27,7 +27,8 @@ enum Api { |
27 | 27 | SaveOrUpdateRoleInfoWithMenu = '/role/saveOrUpdateRoleInfoWithMenu', |
28 | 28 | DeleteRole = '/role', |
29 | 29 | GetAllRoleList = '/role/find/list', |
30 | - BaseUserUrl = '/user' | |
30 | + BaseUserUrl = '/user', | |
31 | + BaseOrganization = '/organization' | |
31 | 32 | } |
32 | 33 | |
33 | 34 | export const getAccountInfo=(userId:string)=> |
... | ... | @@ -36,8 +37,34 @@ export const getAccountInfo=(userId:string)=> |
36 | 37 | export const getAccountList = (params: AccountParams) => |
37 | 38 | defHttp.get<AccountListGetResultModel>({url: Api.AccountList, params}); |
38 | 39 | |
39 | -export const getDeptList = (params?: DeptListItem) => | |
40 | - defHttp.get<DeptListGetResultModel>({url: Api.DeptList, params}); | |
40 | +/** | |
41 | + * 获取组织列表 | |
42 | + * @param params 请求参数 | |
43 | + */ | |
44 | +export const getOrganizationList = (params?: OrganizationListItem) => | |
45 | + defHttp.get<OrganizationListGetResultModel>({url: Api.BaseOrganization+'/me/organizations', params}); | |
46 | + | |
47 | +/** | |
48 | + * 更新或者保存组织 | |
49 | + * @param params | |
50 | + * @param isUpdate | |
51 | + */ | |
52 | +export const saveOrUpdateOrganization = (params?:OrganizationListItem,isUpdate?:boolean) => | |
53 | +{ | |
54 | + if(isUpdate){ | |
55 | + return defHttp.put<OrganizationListGetResultModel>({url: Api.BaseOrganization, params}); | |
56 | + }else{ | |
57 | + return defHttp.post<OrganizationListGetResultModel>({url: Api.BaseOrganization, params}); | |
58 | + } | |
59 | +}; | |
60 | + | |
61 | +/** | |
62 | + * 删除组织 | |
63 | + * @param ids 删除的ID | |
64 | + */ | |
65 | +export const delOrganization = (ids: string[]) => | |
66 | + defHttp.delete({url: Api.BaseOrganization, data: ids}) | |
67 | + | |
41 | 68 | |
42 | 69 | export const getMenuList = (params?: MenuParams) => |
43 | 70 | defHttp.get<MenuListGetResultModel>({url: Api.MenuList, params}); |
... | ... | @@ -98,7 +125,7 @@ export const deleteUser = (ids: string[]) => |
98 | 125 | * 查询当前用户的关系 |
99 | 126 | * @param params |
100 | 127 | */ |
101 | -export const findCurrentUserRelation=(params:RoleOrGroupParam)=> | |
128 | +export const findCurrentUserRelation=(params:RoleOrOrganizationParam)=> | |
102 | 129 | defHttp.post<Array<string>>({ |
103 | 130 | url: Api.BaseUserUrl+"/relation", |
104 | 131 | params:params | ... | ... |
1 | 1 | export default { |
2 | + common:{ | |
3 | + createTime:"create time", | |
4 | + updateTime:"update time", | |
5 | + operation:"operation", | |
6 | + remark:"remark", | |
7 | + enable:"enable", | |
8 | + disable:"disable", | |
9 | + sort:"sort", | |
10 | + status:"status", | |
11 | + }, | |
2 | 12 | tenant:{ |
3 | 13 | tenant:"tenant", |
4 | 14 | tenantManagement:"tenant management", |
5 | 15 | tenantSetting:"tenant setting" |
6 | 16 | }, |
17 | + organization:{ | |
18 | + queryOrganizationName:"organization name", | |
19 | + toolOrganizationList:"organization list", | |
20 | + toolCreateOrganization:"create organization", | |
21 | + toolEditOrganization:"edit organization", | |
22 | + parentOrganization:"parent organization", | |
23 | + }, | |
7 | 24 | dept:{ |
8 | 25 | queryDeptName:"dept name", |
9 | 26 | queryDeptStatus:"status", | ... | ... |
1 | 1 | export default { |
2 | + common:{ | |
3 | + createTime:"创建时间", | |
4 | + updateTime:"更新时间", | |
5 | + operation:"操作", | |
6 | + remark:"备注", | |
7 | + enable:"启用", | |
8 | + disable:"禁用", | |
9 | + sort:"排序", | |
10 | + status:"状态" | |
11 | + }, | |
2 | 12 | tenant:{ |
3 | 13 | tenant:"租户", |
4 | 14 | tenantManagement:"租户管理", |
5 | 15 | tenantSetting:"租户设置" |
6 | 16 | }, |
17 | + organization:{ | |
18 | + queryOrganizationName:"组织名称", | |
19 | + toolOrganizationList:"组织列表", | |
20 | + toolCreateOrganization:"新增组织", | |
21 | + toolEditOrganization:"编辑组织", | |
22 | + parentOrganization:"上级组织", | |
23 | + }, | |
7 | 24 | dept:{ |
8 | 25 | queryDeptName:"部门名称", |
9 | 26 | queryDeptStatus:"状态", | ... | ... |
... | ... | @@ -2,15 +2,15 @@ |
2 | 2 | <BasicModal width="650px" v-bind="$attrs" @register="registerModal" :title="getTitle" |
3 | 3 | @ok="handleSubmit"> |
4 | 4 | <BasicForm @register="registerForm"> |
5 | - <template #groupId="{ model, field }"> | |
5 | + <template #organizationId="{ model, field }"> | |
6 | 6 | <BasicTree |
7 | 7 | v-model:value="model[field]" |
8 | - :treeData="groupTreeData" | |
8 | + :treeData="organizationTreeData" | |
9 | 9 | :replaceFields="{ title: 'name' }" |
10 | 10 | :checked-keys="checkGroup" |
11 | 11 | checkable |
12 | 12 | toolbar |
13 | - title="所辖分组" | |
13 | + title="所属组织" | |
14 | 14 | /> |
15 | 15 | </template> |
16 | 16 | </BasicForm> |
... | ... | @@ -21,10 +21,10 @@ import {defineComponent, ref, computed, unref} from 'vue'; |
21 | 21 | import {BasicModal, useModalInner} from '/@/components/Modal'; |
22 | 22 | import {BasicForm, useForm} from '/@/components/Form/index'; |
23 | 23 | import {accountFormSchema} from './account.data'; |
24 | -import {findCurrentUserRelation, getDeptList, SaveOrUpdateUserInfo} from '/@/api/system/system'; | |
24 | +import {findCurrentUserRelation, getOrganizationList, SaveOrUpdateUserInfo} from '/@/api/system/system'; | |
25 | 25 | import {BasicTree, TreeItem} from "/@/components/Tree"; |
26 | 26 | import {findCurrentUserGroups} from "/@/api/system/group"; |
27 | -import {RoleOrGroupParam} from "/@/api/system/model/systemModel"; | |
27 | +import {RoleOrOrganizationParam} from "/@/api/system/model/systemModel"; | |
28 | 28 | import {useMessage} from "/@/hooks/web/useMessage"; |
29 | 29 | export default defineComponent({ |
30 | 30 | name: 'AccountModal', |
... | ... | @@ -33,7 +33,7 @@ export default defineComponent({ |
33 | 33 | setup(_, {emit}) { |
34 | 34 | const isUpdate = ref(true); |
35 | 35 | const rowId = ref(''); |
36 | - const groupTreeData = ref<TreeItem[]>([]); | |
36 | + const organizationTreeData = ref<TreeItem[]>([]); | |
37 | 37 | const checkGroup = ref<string[]>([]); |
38 | 38 | const [registerForm, {setFieldsValue, updateSchema, resetFields, validate}] = useForm({ |
39 | 39 | labelWidth: 100, |
... | ... | @@ -49,7 +49,7 @@ export default defineComponent({ |
49 | 49 | setModalProps({confirmLoading: false}); |
50 | 50 | isUpdate.value = !!data?.isUpdate; |
51 | 51 | const groupListModel = await findCurrentUserGroups(); |
52 | - if (unref(groupTreeData).length === 0) { | |
52 | + if (unref(organizationTreeData).length === 0) { | |
53 | 53 | let treeValues = new Array<TreeItem>(); |
54 | 54 | groupListModel.map((item) => { |
55 | 55 | const groupData = { |
... | ... | @@ -60,12 +60,12 @@ export default defineComponent({ |
60 | 60 | } |
61 | 61 | treeValues.push(groupData); |
62 | 62 | }) |
63 | - groupTreeData.value = treeValues; | |
63 | + organizationTreeData.value = treeValues; | |
64 | 64 | } |
65 | 65 | |
66 | 66 | if (unref(isUpdate)) { |
67 | 67 | rowId.value = data.record.id; |
68 | - const roleParams = new RoleOrGroupParam(rowId.value,true,false); | |
68 | + const roleParams = new RoleOrOrganizationParam(rowId.value,true,false); | |
69 | 69 | findCurrentUserRelation(roleParams).then((result)=>{ |
70 | 70 | Reflect.set(data.record,"roleIds",result); |
71 | 71 | Reflect.set(data.record,"password","******"); |
... | ... | @@ -73,10 +73,10 @@ export default defineComponent({ |
73 | 73 | ...data.record, |
74 | 74 | }); |
75 | 75 | }) |
76 | - const groupParams = new RoleOrGroupParam(rowId.value,false,true); | |
77 | - checkGroup.value = await findCurrentUserRelation(groupParams); | |
76 | + const organizationParams = new RoleOrOrganizationParam(rowId.value,false,true); | |
77 | + checkGroup.value = await findCurrentUserRelation(organizationParams); | |
78 | 78 | } |
79 | - const deptData = await getDeptList(); | |
79 | + const deptData = await getOrganizationList(); | |
80 | 80 | await updateSchema([ |
81 | 81 | { |
82 | 82 | field: 'username', |
... | ... | @@ -110,7 +110,7 @@ export default defineComponent({ |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - return {registerModal, registerForm, getTitle, handleSubmit, groupTreeData,checkGroup}; | |
113 | + return {registerModal, registerForm, getTitle, handleSubmit, organizationTreeData,checkGroup}; | |
114 | 114 | }, |
115 | 115 | }); |
116 | 116 | </script> | ... | ... |
src/views/system/account/OrganizationIdTree.vue
renamed from
src/views/system/account/DeptTree.vue
1 | 1 | <template> |
2 | 2 | <div class="bg-white m-4 mr-0 overflow-hidden"> |
3 | 3 | <BasicTree |
4 | - title="部门列表" | |
4 | + title="组织列表" | |
5 | 5 | toolbar |
6 | 6 | search |
7 | 7 | :clickRowToExpand="false" |
... | ... | @@ -15,10 +15,10 @@ |
15 | 15 | import { defineComponent, onMounted, ref } from 'vue'; |
16 | 16 | |
17 | 17 | import { BasicTree, TreeItem } from '/@/components/Tree'; |
18 | - import { getDeptList } from '/@/api/system/system'; | |
18 | + import { getOrganizationList } from '/@/api/system/system'; | |
19 | 19 | |
20 | 20 | export default defineComponent({ |
21 | - name: 'DeptTree', | |
21 | + name: 'OrganizationIdTree', | |
22 | 22 | components: { BasicTree }, |
23 | 23 | |
24 | 24 | emits: ['select'], |
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | const treeData = ref<TreeItem[]>([]); |
27 | 27 | |
28 | 28 | async function fetch() { |
29 | - treeData.value = (await getDeptList()) as unknown as TreeItem[]; | |
29 | + treeData.value = (await getOrganizationList()) as unknown as TreeItem[]; | |
30 | 30 | } |
31 | 31 | |
32 | 32 | function handleSelect(keys) { | ... | ... |
... | ... | @@ -168,22 +168,9 @@ export const accountFormSchema: FormSchema[] = [ |
168 | 168 | }, |
169 | 169 | }, |
170 | 170 | { |
171 | - field: 'deptId', | |
172 | - label: '所属部门', | |
173 | - component: 'TreeSelect', | |
174 | - componentProps: { | |
175 | - replaceFields: { | |
176 | - title: 'deptName', | |
177 | - key: 'id', | |
178 | - value: 'id', | |
179 | - }, | |
180 | - }, | |
181 | - required: true, | |
182 | - }, | |
183 | - { | |
184 | - field: 'groupIds', | |
171 | + field: 'organizationIds', | |
185 | 172 | label: ' ', |
186 | 173 | component: 'Input', |
187 | - slot:'groupId', | |
174 | + slot:'organizationId', | |
188 | 175 | }, |
189 | 176 | ]; | ... | ... |
... | ... | @@ -56,7 +56,7 @@ |
56 | 56 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
57 | 57 | import {deleteUser, getAccountList} from '/@/api/system/system'; |
58 | 58 | import { PageWrapper } from '/@/components/Page'; |
59 | - import DeptTree from './DeptTree.vue'; | |
59 | + import DeptTree from './OrganizationIdTree.vue'; | |
60 | 60 | import {Tag} from "ant-design-vue"; |
61 | 61 | import { useModal } from '/@/components/Modal'; |
62 | 62 | import AccountModal from './AccountModal.vue'; | ... | ... |
src/views/system/organization/OrganizationDrawer.vue
renamed from
src/views/system/dept/DeptDrawer.vue
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | @register="registerDrawer" |
5 | 5 | showFooter |
6 | 6 | :title="getTitle" |
7 | - width="50%" | |
7 | + width="30%" | |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | 10 | <BasicForm @register="registerForm"/> |
... | ... | @@ -12,62 +12,52 @@ |
12 | 12 | </template> |
13 | 13 | <script lang="ts"> |
14 | 14 | import {defineComponent, ref, computed, unref} from 'vue'; |
15 | -import {BasicForm, useForm} from '/@/components/Form/index'; | |
16 | -import {formSchema} from './dept.data'; | |
15 | +import {BasicForm, useForm} from '/@/components/Form'; | |
16 | +import {formSchema} from './organization.data'; | |
17 | 17 | import {BasicDrawer, useDrawerInner} from '/@/components/Drawer'; |
18 | - | |
19 | -// 加载部门 | |
20 | -import { getDeptList } from '/@/api/system/dept'; | |
21 | 18 | import {useI18n} from "/@/hooks/web/useI18n"; |
22 | -import {saveOrEditDeptApi} from "/@/api/system/dept"; | |
23 | - | |
24 | - | |
19 | +import {getOrganizationList, saveOrUpdateOrganization} from "/@/api/system/system"; | |
25 | 20 | export default defineComponent({ |
26 | - name: 'DeptDrawer', | |
21 | + name: 'OrganizationDrawer', | |
27 | 22 | components: {BasicDrawer, BasicForm}, |
28 | 23 | emits: ['success', 'register'], |
29 | 24 | setup(_, {emit}) { |
30 | 25 | const isUpdate = ref(true); |
31 | - let deptId,tenantCode,creator,createTime; | |
26 | + let organizationId; | |
32 | 27 | |
33 | 28 | const [registerForm, {resetFields, setFieldsValue, updateSchema, validate}] = useForm({ |
34 | 29 | labelWidth: 100, |
35 | 30 | schemas: formSchema, |
36 | - showActionButtonGroup: false, | |
37 | - baseColProps: {lg: 12, md: 24}, | |
31 | + showActionButtonGroup: false | |
38 | 32 | }); |
39 | 33 | const {t} = useI18n(); //加载国际化 |
40 | 34 | |
41 | 35 | //默认传递页面数据 |
42 | 36 | const [registerDrawer, {setDrawerProps, closeDrawer}] = useDrawerInner(async (data) => { |
43 | - resetFields(); | |
37 | + await resetFields(); | |
44 | 38 | setDrawerProps({confirmLoading: false}); |
45 | 39 | isUpdate.value = !!data?.isUpdate; |
46 | 40 | |
47 | 41 | //如果是编辑操作,设置页面数据 |
48 | 42 | if (unref(isUpdate)) { |
49 | 43 | //为表单赋值 |
50 | - setFieldsValue({ | |
44 | + await setFieldsValue({ | |
51 | 45 | ...data.record, |
52 | 46 | }); |
53 | 47 | |
54 | 48 | } |
55 | 49 | if (isUpdate.value) { |
56 | - tenantCode= Reflect.get(data.record, 'tenantCode'); | |
57 | - creator= Reflect.get(data.record, 'creator'); | |
58 | - createTime= Reflect.get(data.record, 'createTime'); | |
59 | - deptId = Reflect.get(data.record, 'id'); | |
50 | + organizationId = Reflect.get(data.record, 'id'); | |
60 | 51 | } |
61 | - //加载部门 | |
62 | - let treeData = await getDeptList(); | |
63 | - updateSchema({ | |
52 | + let treeData = await getOrganizationList(); | |
53 | + await updateSchema({ | |
64 | 54 | field: 'parentId', |
65 | 55 | componentProps: {treeData}, |
66 | 56 | }); |
67 | 57 | }); |
68 | 58 | |
69 | 59 | //得到页面标题 |
70 | - const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.dept.toolCreateDept') : t('routes.common.dept.toolEditDept'))); | |
60 | + const getTitle = computed(() => (!unref(isUpdate) ? t('routes.common.organization.toolCreateOrganization') : t('routes.common.organization.toolEditOrganization'))); | |
71 | 61 | |
72 | 62 | //提交按钮 |
73 | 63 | async function handleSubmit() { |
... | ... | @@ -76,19 +66,9 @@ export default defineComponent({ |
76 | 66 | setDrawerProps({confirmLoading: true}); |
77 | 67 | |
78 | 68 | if (isUpdate.value) { |
79 | - Reflect.set(values, 'id', deptId); | |
80 | - Reflect.set(values, 'tenantCode', tenantCode); | |
81 | - Reflect.set(values, 'creator', creator); | |
82 | - Reflect.set(values, 'createTime', createTime); | |
69 | + Reflect.set(values, 'id', organizationId); | |
83 | 70 | } |
84 | - | |
85 | - // TODO custom api | |
86 | - // console.log("-------------提交后台的参数-------------------"); | |
87 | - // console.log(values); | |
88 | - const data = await saveOrEditDeptApi(values, isUpdate.value); | |
89 | - console.log("_______保存返回结果____data:",data); | |
90 | - | |
91 | - | |
71 | + await saveOrUpdateOrganization(values, isUpdate.value); | |
92 | 72 | closeDrawer();//关闭侧框 |
93 | 73 | emit('success'); |
94 | 74 | } finally { | ... | ... |
src/views/system/organization/index.vue
renamed from
src/views/system/dept/index.vue
... | ... | @@ -3,18 +3,19 @@ |
3 | 3 | <BasicTable @register="registerTable" @fetch-success="onFetchSuccess"> |
4 | 4 | <template #toolbar> |
5 | 5 | <a-button type="primary" @click="handleCreate"> |
6 | - <!-- 新增部门--> | |
7 | - {{ getI18nCreateDept }} | |
6 | + {{ getI18n }} | |
8 | 7 | </a-button> |
9 | 8 | </template> |
10 | 9 | <template #action="{ record }"> |
11 | 10 | <TableAction |
12 | 11 | :actions="[ |
13 | 12 | { |
13 | + label:'编辑', | |
14 | 14 | icon: 'clarity:note-edit-line', |
15 | 15 | onClick: handleEdit.bind(null, record), |
16 | 16 | }, |
17 | 17 | { |
18 | + label:'删除', | |
18 | 19 | icon: 'ant-design:delete-outlined', |
19 | 20 | color: 'error', |
20 | 21 | popConfirm: { |
... | ... | @@ -33,16 +34,14 @@ |
33 | 34 | import {computed, defineComponent, nextTick} from 'vue'; |
34 | 35 | |
35 | 36 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
36 | - import { getDeptList } from '/@/api/system/dept'; | |
37 | 37 | |
38 | 38 | // 加载自定义侧边弹出框 组件 |
39 | 39 | import {useDrawer} from '/@/components/Drawer'; |
40 | - import DeptDrawer from './DeptDrawer.vue'; | |
41 | - | |
42 | - import { columns, searchFormSchema } from './dept.data'; | |
43 | - import {delDept} from "/@/api/system/dept"; | |
40 | + import DeptDrawer from './OrganizationDrawer.vue'; | |
41 | + import { columns } from './organization.data'; | |
44 | 42 | import {useI18n} from "/@/hooks/web/useI18n"; |
45 | - import {notification} from "ant-design-vue"; | |
43 | + import {delOrganization, getOrganizationList} from "/@/api/system/system"; | |
44 | + import {useMessage} from "/@/hooks/web/useMessage"; | |
46 | 45 | |
47 | 46 | export default defineComponent({ |
48 | 47 | name: 'DeptManagement', |
... | ... | @@ -50,28 +49,23 @@ |
50 | 49 | setup() { |
51 | 50 | const [registerModal, { openDrawer }] = useDrawer(); |
52 | 51 | const {t} = useI18n(); //加载国际化 |
53 | - // 新增部门 | |
54 | - const getI18nCreateDept = computed(() => t('routes.common.dept.toolCreateDept')); | |
55 | - | |
52 | + const getI18n = computed(() => t('routes.common.organization.toolCreateOrganization')); | |
53 | + const {createMessage} = useMessage(); | |
56 | 54 | const [registerTable, { reload,expandAll }] = useTable({ |
57 | - title: t('routes.common.dept.toolDeptList'), | |
58 | - api: getDeptList, | |
55 | + title: t('routes.common.organization.toolOrganizationList'), | |
56 | + api: getOrganizationList, | |
59 | 57 | columns, |
60 | - formConfig: { | |
61 | - labelWidth: 120, | |
62 | - schemas: searchFormSchema, | |
63 | - }, | |
64 | 58 | isTreeTable: true, |
65 | 59 | pagination: false, |
66 | 60 | striped: false, |
67 | - useSearchForm: true, | |
61 | + useSearchForm: false, | |
68 | 62 | showTableSetting: true, |
69 | 63 | bordered: true, |
70 | 64 | showIndexColumn: false, |
71 | 65 | canResize: false, |
72 | 66 | actionColumn: { |
73 | 67 | width: 80, |
74 | - title: t('routes.common.dept.tableTitleDeptOperation'),//操作 | |
68 | + title: t('routes.common.common.operation'),//操作 | |
75 | 69 | dataIndex: 'action', |
76 | 70 | slots: { customRender: 'action' }, |
77 | 71 | fixed: undefined, |
... | ... | @@ -102,13 +96,10 @@ |
102 | 96 | // console.log(record); |
103 | 97 | try { |
104 | 98 | let ids = [record.id,]; |
105 | - await delDept(ids); | |
106 | - notification.success({ | |
107 | - message: "成功", | |
108 | - description: "删除部门成功", | |
109 | - duration: 3, | |
99 | + await delOrganization(ids).then(()=>{ | |
100 | + createMessage.success("删除组织成功"); | |
101 | + handleSuccess(); | |
110 | 102 | }); |
111 | - await reload(); | |
112 | 103 | } catch (e) { |
113 | 104 | return Promise.reject(e); |
114 | 105 | } |
... | ... | @@ -126,7 +117,7 @@ |
126 | 117 | return { |
127 | 118 | registerTable, |
128 | 119 | registerModal, |
129 | - getI18nCreateDept, | |
120 | + getI18n, | |
130 | 121 | getDeleteTitle, |
131 | 122 | handleCreate, |
132 | 123 | handleEdit, | ... | ... |
src/views/system/organization/organization.data.ts
renamed from
src/views/system/dept/dept.data.ts
1 | 1 | import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | -import { h } from 'vue'; | |
4 | -import { Tag } from 'ant-design-vue'; | |
5 | 3 | import {useI18n} from "/@/hooks/web/useI18n"; |
6 | 4 | const { t } = useI18n(); |
7 | 5 | |
8 | 6 | export const columns: BasicColumn[] = [ |
9 | 7 | { |
10 | - title: t('routes.common.dept.queryDeptName'),//部门名称 | |
11 | - dataIndex: 'deptName', | |
8 | + title: t('routes.common.organization.queryOrganizationName'), | |
9 | + dataIndex: 'name', | |
12 | 10 | width: 160, |
13 | 11 | align: 'left', |
14 | 12 | }, |
15 | 13 | { |
16 | - title: t('routes.common.dept.tableTitleDeptSort'),//排序 | |
17 | - dataIndex: 'orderNo', | |
14 | + title: t('routes.common.common.sort'),//排序 | |
15 | + dataIndex: 'sort', | |
18 | 16 | width: 50, |
19 | 17 | }, |
20 | 18 | { |
21 | - title: t('routes.common.dept.queryDeptStatus'),//状态 | |
22 | - dataIndex: 'status', | |
23 | - width: 80, | |
24 | - customRender: ({ record }) => { | |
25 | - const status = record.status; | |
26 | - const enable = ~~status === 0; | |
27 | - const color = enable ? 'green' : 'red'; | |
28 | - const text = enable ? t('routes.common.dept.drawerTitleDeptEnable') : t('routes.common.dept.drawerTitleDeptDisable'); | |
29 | - // const text = enable ? '启用' : '停用'; | |
30 | - return h(Tag, { color: color }, () => text); | |
31 | - }, | |
32 | - }, | |
33 | - { | |
34 | - title: t('routes.common.dept.tableTitleDeptCreateTime'),//创建时间 | |
19 | + title: t('routes.common.common.createTime'),//创建时间 | |
35 | 20 | dataIndex: 'createTime', |
36 | 21 | width: 180, |
37 | 22 | }, |
38 | 23 | { |
39 | - title: t('routes.common.dept.tableTitleMemo'),//备注 | |
24 | + title: t('routes.common.common.remark'),//备注 | |
40 | 25 | dataIndex: 'remark', |
26 | + width: 300, | |
41 | 27 | }, |
42 | 28 | ]; |
43 | - | |
44 | -export const searchFormSchema: FormSchema[] = [ | |
45 | - { | |
46 | - field: 'deptName', | |
47 | - label: t('routes.common.dept.queryDeptName'),//部门名称 | |
48 | - component: 'Input', | |
49 | - colProps: { span: 8 }, | |
50 | - }, | |
51 | - { | |
52 | - field: 'status', | |
53 | - label: t('routes.common.dept.queryDeptStatus'),//状态 | |
54 | - component: 'Select', | |
55 | - componentProps: { | |
56 | - options: [ | |
57 | - { label: t('routes.common.dept.drawerTitleDeptEnable'), value: 0 }, | |
58 | - // { label: '启用', value: 0 }, | |
59 | - { label: t('routes.common.dept.drawerTitleDeptDisable'), value: 1 }, | |
60 | - // { label: '停用', value: 1 }, | |
61 | - ], | |
62 | - }, | |
63 | - colProps: { span: 8 }, | |
64 | - }, | |
65 | -]; | |
66 | - | |
67 | 29 | export const formSchema: FormSchema[] = [ |
68 | 30 | { |
69 | - field: 'deptName', | |
70 | - label: t('routes.common.dept.queryDeptName'),//部门名称 | |
71 | - component: 'Input', | |
72 | - required: true, | |
73 | - }, | |
74 | - { | |
75 | 31 | field: 'parentId', |
76 | - label: t('routes.common.dept.drawerTitleDeptParentDept'),//上级部门 | |
32 | + label: t('routes.common.organization.parentOrganization'), | |
77 | 33 | component: 'TreeSelect', |
78 | 34 | componentProps: { |
79 | 35 | replaceFields: { |
80 | - title: 'deptName', | |
36 | + title: 'name', | |
81 | 37 | key: 'id', |
82 | 38 | value: 'id', |
83 | 39 | }, |
... | ... | @@ -86,28 +42,19 @@ export const formSchema: FormSchema[] = [ |
86 | 42 | // required: true, |
87 | 43 | }, |
88 | 44 | { |
89 | - field: 'orderNo', | |
90 | - label: t('routes.common.dept.tableTitleDeptSort'),//排序 | |
91 | - component: 'InputNumber', | |
45 | + field: 'name', | |
46 | + label: t('routes.common.organization.queryOrganizationName'), | |
47 | + component: 'Input', | |
92 | 48 | required: true, |
93 | 49 | }, |
94 | 50 | { |
95 | - field: 'status', | |
96 | - label: t('routes.common.dept.queryDeptStatus'),//状态 | |
97 | - component: 'RadioButtonGroup', | |
98 | - defaultValue: 0, | |
99 | - componentProps: { | |
100 | - options: [ | |
101 | - { label: t('routes.common.dept.drawerTitleDeptEnable'), value: 0 }, | |
102 | - // { label: '启用', value: 0 }, | |
103 | - { label: t('routes.common.dept.drawerTitleDeptDisable'), value: 1 }, | |
104 | - // { label: '停用', value: 1 }, | |
105 | - ], | |
106 | - }, | |
51 | + field: 'sort', | |
52 | + label: t('routes.common.common.sort'),//排序 | |
53 | + component: 'InputNumber', | |
107 | 54 | required: true, |
108 | 55 | }, |
109 | 56 | { |
110 | - label: t('routes.common.dept.tableTitleMemo'),//备注 | |
57 | + label: t('routes.common.common.remark'),//备注 | |
111 | 58 | field: 'remark', |
112 | 59 | component: 'InputTextArea', |
113 | 60 | }, | ... | ... |