Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
intelligent_qp_manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
intelligent_qp_manager
Commits
63a8ea4b
Commit
63a8ea4b
authored
Oct 30, 2024
by
baiyinhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字典管理代码提交
parent
ff3406c4
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1614 additions
and
124 deletions
+1614
-124
systemModel.ts
src/api/demo/model/systemModel.ts
+88
-1
system.ts
src/api/demo/system.ts
+56
-1
dict.ts
src/api/system/dict/dict.ts
+93
-0
dicts.ts
src/api/system/dict/dicts.ts
+11
-10
index.ts
src/router/routes/index.ts
+26
-2
DictModal.vue
src/views/system/dict/DictModal.vue
+180
-0
DictModal.vue
src/views/system/dict/data/DictModal.vue
+188
-0
dict.data.ts
src/views/system/dict/data/dict.data.ts
+192
-0
dictForm.data.ts
src/views/system/dict/data/dictForm.data.ts
+97
-0
index.vue
src/views/system/dict/data/index.vue
+116
-0
dict.data.ts
src/views/system/dict/dict.data.ts
+177
-0
dictForm.data.ts
src/views/system/dict/dictForm.data.ts
+172
-0
index.vue
src/views/system/dict/index.vue
+102
-5
AccountModal.vue
src/views/system/user/AccountModal.vue
+51
-42
DeptTree.vue
src/views/system/user/DeptTree.vue
+1
-1
account.data.ts
src/views/system/user/account.data.ts
+11
-14
importModal.vue
src/views/system/user/importModal.vue
+1
-1
index.vue
src/views/system/user/index.vue
+1
-1
resetPassword.vue
src/views/system/user/resetPassword.vue
+51
-46
No files found.
src/api/demo/model/systemModel.ts
View file @
63a8ea4b
...
...
@@ -11,8 +11,47 @@ export type RoleParams = {
status
?:
string
;
};
// 创建字典查询参数
export
type
DictParams
=
{
dictName
?:
string
;
flag
?:
number
;
};
export
type
RolePageParams
=
BasicPageParams
&
RoleParams
;
// 创建字典分页查询参数
export
type
DictPageParams
=
BasicPageParams
&
RoleParams
;
// 创建字典路由跳转后查询参数
export
type
DictRouteParams
=
{
businessId
?:
number
;
};
// 创建字典新增参数
export
type
DictAddParams
=
{
dictName
?:
string
;
dictType
?:
string
;
dataId
?:
string
;
parentId
?:
string
;
status
?:
string
;
flag
?:
number
;
remarks
?:
string
;
};
// 创建字典修改参数DictEditParams
export
type
DictEditParams
=
{
remarks
?:
string
;
createBy
?:
string
;
createDate
?:
string
;
updateBy
?:
string
;
updateDate
?:
string
;
delFlag
?:
string
;
flag
?:
string
;
businessId
?:
number
;
dictType
?:
String
;
dictName
?:
String
;
parentId
?:
String
;
dataId
?:
number
;
dictSort
?:
String
;
remark
?:
String
;
username
?:
String
;
types
?:
String
;
};
export
type
DeptParams
=
{
deptName
?:
string
;
status
?:
string
;
...
...
@@ -60,7 +99,45 @@ export interface RoleListItem {
orderNo
:
string
;
createTime
:
string
;
}
// 创建字典列表参数
export
interface
DictListItem
{
id
:
string
;
beginTime
:
Date
;
endTime
:
Date
;
dictName
:
string
;
dictType
:
string
;
flag
:
number
;
}
// 创建字典详情新增参数
export
type
DictDataAddParams
=
{
dictName
?:
string
;
dictType
?:
string
;
dataId
?:
string
;
parentId
?:
string
;
status
?:
string
;
flag
?:
number
;
remarks
?:
string
;
};
// 创建字典数据详情列表参数
export
interface
DictDataItem
{
businessId
:
number
;
createBy
:
string
;
createDate
:
string
;
cssClass
:
string
;
delFlag
:
string
;
dictLabel
:
string
;
dictSort
:
number
;
dictType
:
string
;
dictValue
:
string
;
flag
:
string
;
isDefault
:
string
;
listClass
:
string
;
remark
:
string
;
remarks
:
string
;
updateBy
:
string
;
updateDate
:
string
;
}
/**
* @description: Request list return value
*/
...
...
@@ -73,3 +150,13 @@ export type MenuListGetResultModel = BasicFetchResult<MenuListItem>;
export
type
RolePageListGetResultModel
=
BasicFetchResult
<
RoleListItem
>
;
export
type
RoleListGetResultModel
=
RoleListItem
[];
//暴露Dict查询参数
export
type
DictPageListGetResultModel
=
BasicFetchResult
<
DictListItem
>
;
export
type
DictListGetResultModel
=
DictListItem
[];
//暴露Dict路由跳转后查询参数
export
type
DictRouteListGetResultModel
=
BasicFetchResult
<
DictRouteParams
>
;
export
type
DictRouteModel
=
DictRouteParams
[];
src/api/demo/system.ts
View file @
63a8ea4b
import
{
useRoute
}
from
'vue-router'
;
import
{
AccountParams
,
DeptListItem
,
...
...
@@ -9,6 +10,15 @@ import {
AccountListGetResultModel
,
RolePageListGetResultModel
,
RoleListGetResultModel
,
DictParams
,
DictPageParams
,
DictAddParams
,
DictDataItem
,
DictRouteParams
,
DictPageListGetResultModel
,
DictListGetResultModel
,
DictRouteListGetResultModel
,
DictDataGetResultModel
,
}
from
'./model/systemModel'
;
import
{
defHttp
}
from
'@/utils/http/axios'
;
...
...
@@ -21,13 +31,31 @@ enum Api {
MenuList
=
'/system/getMenuList'
,
RolePageList
=
'/system/getRoleListByPage'
,
GetAllRoleList
=
'/system/role/listAll'
,
// 创建字典查询接口
DictPageList
=
'/system/dict/type/list'
,
// 创建字典新增接口
AddDict
=
'/system/dict/type/add'
,
//创建字典修改接口
updateDict
=
'/system/dict/type/update'
,
//创建字典删除接口
deleteDict
=
'/system/dict/type/deleteLogical/'
,
//创建字典详情接口
DictData
=
'/system/dict/data/list'
,
//创建字典跳转后查询详情接口/dict/type/detail/
DictRouteQuery
=
'/system/dict/type/detail/'
,
//创建字典跳转后新增接口
DictRouteAdd
=
'/system/dict/data/add'
,
//创建字典跳转后修改接口
DictRouteUpdate
=
'/system/dict/data/update'
,
//创建字典跳转后删除接口
DictRouteDelete
=
'/system/dict/data/deleteLogical/'
,
}
export
const
getAccountList
=
(
params
:
AccountParams
)
=>
defHttp
.
get
<
AccountListGetResultModel
>
({
url
:
Api
.
AccountList
,
params
});
export
const
deleteUser
=
(
params
?:
any
)
=>
defHttp
.
delete
<
any
>
({
url
:
Api
.
deleteUserApi
+
params
.
id
});
defHttp
.
delete
<
any
>
({
url
:
Api
.
deleteUserApi
+
params
.
id
});
export
const
getDeptList
=
(
params
?:
DeptListItem
)
=>
defHttp
.
get
<
DeptListGetResultModel
>
({
url
:
Api
.
DeptList
,
params
});
...
...
@@ -46,3 +74,30 @@ export const setRoleStatus = (id: number, status: string) =>
export
const
isAccountExist
=
(
account
:
string
)
=>
defHttp
.
post
({
url
:
Api
.
IsAccountExist
,
params
:
{
account
}
},
{
errorMessageMode
:
'none'
});
//创建字典查询接口
export
const
getAllDictList
=
(
params
?:
DictParams
)
=>
defHttp
.
get
<
DictPageListGetResultModel
>
({
url
:
Api
.
DictPageList
,
params
});
export
const
getDictListByPage
=
(
params
?:
DictPageParams
)
=>
defHttp
.
get
<
DictListGetResultModel
>
({
url
:
Api
.
DictPageList
,
params
});
//创建字典跳转后查询详情接口/dict/type/detail/
export
const
getDict
=
(
params
?:
any
)
=>
defHttp
.
get
({
url
:
Api
.
DictRouteQuery
+
params
});
//创建字典新增接口
export
const
addDict
=
(
params
?:
DictAddParams
)
=>
defHttp
.
post
({
url
:
Api
.
AddDict
,
params
});
//创建字典修改接口
export
const
updateDict
=
(
params
?:
DictAddParams
)
=>
defHttp
.
post
({
url
:
Api
.
updateDict
,
params
});
//创建字典删除接口
export
const
deleteDict
=
(
params
?:
any
)
=>
defHttp
.
delete
<
any
>
({
url
:
Api
.
deleteDict
+
params
.
id
});
//创建字典详情接口
export
const
getDictData
=
(
params
?:
DictParams
)
=>
defHttp
.
get
<
DictListGetResultModel
>
({
url
:
Api
.
DictData
,
params
});
//创建字典跳转后查询详情接口/dict/type/detail/
export
const
getDictQueryData
=
(
params
?:
any
)
=>
defHttp
.
get
({
url
:
Api
.
DictRouteQuery
+
params
});
//创建字典数据新增接口
export
const
addDictData
=
(
params
?:
any
)
=>
defHttp
.
post
({
url
:
Api
.
DictRouteAdd
,
params
});
//创建字典数据修改接口
export
const
upDateDictData
=
(
params
?:
any
)
=>
defHttp
.
post
({
url
:
Api
.
DictRouteUpdate
,
params
});
//创建字典数据删除接口
export
const
deleteDictRoute
=
(
params
?:
any
)
=>
defHttp
.
post
({
url
:
Api
.
DictRouteDelete
,
params
});
src/api/system/dict/dict.ts
0 → 100644
View file @
63a8ea4b
import
{
AccountParams
,
DeptListItem
,
MenuParams
,
RoleParams
,
RolePageParams
,
MenuListGetResultModel
,
DeptListGetResultModel
,
AccountListGetResultModel
,
RolePageListGetResultModel
,
RoleListGetResultModel
,
DictParams
,
DictPageParams
,
DictAddParams
,
DictEditParams
,
DictPageListGetResultModel
,
DictListGetResultModel
,
DictDataAddParams
,
}
from
'../../demo/model/systemModel'
;
import
{
defHttp
}
from
'@/utils/http/axios'
;
enum
Api
{
addUser
=
'/system/user/add'
,
userDetail
=
'/system/user/'
,
updataApi
=
'/system/user/update'
,
changeFlag
=
'/system/dict/type/update/'
,
changeDataFlagApi
=
'/system/dict/data/update/'
,
addDict
=
'/system/dict/type/add'
,
addDataDict
=
'/system/dict/data/add'
,
// updateDict = '/system/dict/type/update/',
dictDetail
=
'/system/dict/type/'
,
dictDataDetail
=
'/system/dict/data/'
,
}
/** 用户add*/
export
const
addUserApi
=
(
params
:
any
)
=>
defHttp
.
post
({
url
:
Api
.
addUser
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
/** 获取用户详情信息*/
export
const
UserDetailApi
=
(
params
:
any
)
=>
defHttp
.
get
<
any
>
({
url
:
Api
.
userDetail
+
params
});
/** 用户信息编辑*/
export
const
UserUpdataApi
=
(
params
:
any
)
=>
defHttp
.
put
<
any
>
({
url
:
Api
.
updataApi
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
/** 字典Add*/
export
const
addDict
=
(
params
:
DictAddParams
)
=>
defHttp
.
post
({
url
:
Api
.
addDict
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
/** 字典数据Add*/
export
const
addDataDict
=
(
params
:
DictDataAddParams
)
=>
defHttp
.
post
({
url
:
Api
.
addDataDict
,
params
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
/** 字典编辑*/
// export const updateDict = (params: any) =>
// defHttp.put<any>({
// url: Api.updateDict + params.businessId,
// params: params,
// headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
// });
/** 获取字典详情信息*/
export
const
DictDetailApi
=
(
params
:
any
)
=>
defHttp
.
get
<
any
>
({
url
:
Api
.
dictDetail
+
params
});
/** 字典状态启用停用编辑*/
export
const
changeFlagApi
=
(
params
:
any
)
=>
defHttp
.
put
<
any
>
({
url
:
Api
.
changeFlag
+
params
.
businessId
,
data
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
/** 获取字典数据详情信息*/
export
const
DictDataDetailApi
=
(
params
:
any
)
=>
defHttp
.
get
<
any
>
({
url
:
Api
.
dictDataDetail
+
params
});
/** 字典详情状态启用停用编辑*/
export
const
changeDataFlagApi
=
(
params
:
any
)
=>
defHttp
.
put
<
any
>
({
url
:
Api
.
changeDataFlagApi
+
params
.
businessId
,
data
:
params
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
},
});
src/api/system/
user/user
.ts
→
src/api/system/
dict/dicts
.ts
View file @
63a8ea4b
...
...
@@ -11,9 +11,9 @@ import {
RoleListGetResultModel
,
}
from
'../../demo/model/systemModel'
;
import
{
defHttp
}
from
'@/utils/http/axios'
;
import
{
UploadFileParams
}
from
"#/axios"
;
import
{
AxiosProgressEvent
}
from
"axios"
;
import
{
UploadApiResult
}
from
"@/api/sys/model/uploadModel"
;
import
{
UploadFileParams
}
from
'#/axios'
;
import
{
AxiosProgressEvent
}
from
'axios'
;
import
{
UploadApiResult
}
from
'@/api/sys/model/uploadModel'
;
enum
Api
{
addUser
=
'/system/user/add'
,
...
...
@@ -34,15 +34,17 @@ export const getAccountList = (params: AccountParams) =>
/** 用户列表导出*/
export
const
exportUserList
=
(
params
:
AccountParams
)
=>
defHttp
.
get
<
AccountListGetResultModel
>
({
url
:
Api
.
exportApi
,
params
,
responseType
:
'blob'
});
defHttp
.
get
<
AccountListGetResultModel
>
({
url
:
Api
.
exportApi
,
params
,
responseType
:
'blob'
});
/** 用户导入模板下载*/
export
const
downImportTemplate
=
()
=>
defHttp
.
get
<
any
>
({
url
:
Api
.
importTemplateApi
,
responseType
:
'blob'
});
defHttp
.
get
<
any
>
({
url
:
Api
.
importTemplateApi
,
responseType
:
'blob'
});
/** 用户导入*/
export
const
userImport
=
(
params
:
UploadFileParams
,
onUploadProgress
:
(
progressEvent
:
AxiosProgressEvent
)
=>
void
,)
=>
export
const
userImport
=
(
params
:
UploadFileParams
,
onUploadProgress
:
(
progressEvent
:
AxiosProgressEvent
)
=>
void
,
)
=>
defHttp
.
uploadFile
<
UploadApiResult
>
(
{
url
:
Api
.
userImportApi
,
...
...
@@ -52,7 +54,7 @@ export const userImport = (params: UploadFileParams,
);
/** 用户删除*/
export
const
deleteUser
=
(
params
?:
any
)
=>
defHttp
.
delete
<
any
>
({
url
:
Api
.
deleteUserApi
+
params
.
id
});
defHttp
.
delete
<
any
>
({
url
:
Api
.
deleteUserApi
+
params
.
id
});
/** 用户add*/
export
const
addUserApi
=
(
params
:
any
)
=>
...
...
@@ -63,8 +65,7 @@ export const addUserApi = (params: any) =>
});
/** 获取用户详情信息*/
export
const
UserDetailApi
=
(
params
:
any
)
=>
defHttp
.
get
<
any
>
({
url
:
Api
.
userDetail
+
params
,
});
export
const
UserDetailApi
=
(
params
:
any
)
=>
defHttp
.
get
<
any
>
({
url
:
Api
.
userDetail
+
params
});
/** 用户信息编辑*/
export
const
UserUpdataApi
=
(
params
:
any
)
=>
...
...
src/router/routes/index.ts
View file @
63a8ea4b
import
type
{
AppRouteRecordRaw
,
AppRouteModule
}
from
'@/router/types'
;
import
{
PAGE_NOT_FOUND_ROUTE
,
REDIRECT_ROUTE
}
from
'@/router/routes/basic'
;
import
{
LAYOUT
}
from
'@/router/constant'
;
import
{
mainOutRoutes
}
from
'./mainOut'
;
import
{
PageEnum
}
from
'@/enums/pageEnum'
;
import
{
t
}
from
'@/hooks/web/useI18n'
;
...
...
@@ -37,11 +37,35 @@ export const LoginRoute: AppRouteRecordRaw = {
title
:
t
(
'routes.basic.login'
),
},
};
//10/24 10点19分 字典类型详情页路由
export
const
DictRoute
:
AppRouteRecordRaw
=
{
path
:
'/dict'
,
name
:
'Dict'
,
component
:
LAYOUT
,
meta
:
{
title
:
'字典管理'
,
icon
:
''
,
hidden
:
true
,
currentActiveMenu
:
'/system/dict'
,
},
children
:
[
{
path
:
'type/data/:dictId(
\\
d+)'
,
name
:
'Data'
,
component
:
()
=>
import
(
'@/views/system/dict/data/index.vue'
),
meta
:
{
title
:
'字典数据'
,
icon
:
''
,
},
},
],
};
// Basic routing without permission
//
未经许可
的基本路由
//
没有权限要求
的基本路由
export
const
basicRoutes
=
[
LoginRoute
,
DictRoute
,
// RootRoute,
...
mainOutRoutes
,
REDIRECT_ROUTE
,
...
...
src/views/system/dict/DictModal.vue
0 → 100644
View file @
63a8ea4b
<
template
>
<BasicModal
v-bind=
"$attrs"
@
register=
"registerModal"
:title=
"getTitle"
@
ok=
"handleSubmit"
>
<BasicForm
@
register=
"registerForm"
/>
</BasicModal>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
computed
,
unref
,
reactive
}
from
'vue'
;
import
{
BasicModal
,
useModalInner
}
from
'@/components/Modal'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
dictFormSchema
}
from
'./dictForm.data'
;
import
{
getDeptList
,
getAllRoleList
}
from
'@/api/demo/system'
;
import
{
addUserApi
,
UserDetailApi
,
UserUpdataApi
}
from
'@/api/system/dict/dicts'
;
import
{
addDict
,
changeFlagApi
,
DictDetailApi
}
from
'@/api/system/dict/dict'
;
import
{
encryptTwo
}
from
'../../../utils/jsencrypt.js'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
defineOptions
({
name
:
'DictModal'
});
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
{
createMessage
}
=
useMessage
();
const
isUpdate
=
ref
(
true
);
const
rowId
=
ref
(
''
);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const
[
registerForm
,
{
setFieldsValue
,
updateSchema
,
resetFields
,
validate
}]
=
useForm
({
labelWidth
:
100
,
baseColProps
:
{
span
:
24
},
schemas
:
dictFormSchema
,
showActionButtonGroup
:
false
,
actionColOptions
:
{
span
:
23
,
},
});
//初始化弹框
const
[
registerModal
,
{
setModalProps
,
closeModal
}]
=
useModalInner
(
async
(
data
)
=>
{
resetFields
();
setModalProps
({
confirmLoading
:
false
});
isUpdate
.
value
=
!!
data
?.
isUpdate
;
if
(
unref
(
isUpdate
))
{
// 获取行数据的id
rowId
.
value
=
data
.
record
.
businessId
;
// 通过id获取行详情信息
DictDetailApi
(
rowId
.
value
).
then
((
res
)
=>
{
const
form
=
res
.
data
;
// 数据处理反显用户角色
// const roleData = res.data.roleIds.split(',');
// form.roleList = [];
// roleData.forEach((item) => {
// const id = Number(item);
// form.roleList.push(id);
// });
// 塞值
setFieldsValue
({
...
form
,
});
});
}
const
treeData
=
await
getDeptList
();
const
treeList
=
handleTree
(
treeData
.
data
,
'businessId'
,
undefined
,
undefined
,
undefined
);
updateSchema
([
{
field
:
'username'
,
show
:
!
unref
(
isUpdate
),
},
{
field
:
'password'
,
show
:
!
unref
(
isUpdate
),
},
{
field
:
'flag'
,
show
:
!
unref
(
isUpdate
),
},
{
field
:
'deptId'
,
componentProps
:
{
treeData
:
treeList
,
},
},
]);
});
const
getTitle
=
computed
(()
=>
(
!
unref
(
isUpdate
)
?
'新增字典信息'
:
'编辑字典信息'
));
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
id
=
id
||
'id'
;
parentId
=
parentId
||
'parentId'
;
children
=
children
||
'children'
;
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
((
item
)
=>
{
return
item
[
parentId
];
}),
)
||
0
;
// 对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
// 循环所有项
const
treeData
=
cloneData
.
filter
((
father
)
=>
{
const
branchArr
=
cloneData
.
filter
((
child
)
=>
{
// 返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
];
});
branchArr
.
length
>
0
?
(
father
.
children
=
branchArr
)
:
''
;
// 返回第一层
return
father
[
parentId
]
===
rootId
;
});
return
treeData
!==
''
?
treeData
:
data
;
}
async
function
handleSubmit
()
{
try
{
const
values
=
await
validate
();
setModalProps
({
confirmLoading
:
true
});
// TODO custom api
console
.
log
(
values
);
console
.
log
(
rowId
,
'提交之前11打印信息'
);
// 编辑
if
(
unref
(
isUpdate
))
{
values
.
businessId
=
rowId
.
value
;
// values.remarks: 111
// values.createBy: 1
// values.createDate: 2024-10-17 15:34:32
// values.updateBy: 1
// values.updateDate: 2024-10-17 15:34:32
// values.delFlag: 0
// values.flag: 1
// values.businessId: 300
// values.dictType = rowId.value.dictType;
// values.dictName = rowId.value.dictName;
// values.parentId:
// values.dataId:
// values.dictSort:
// values.remark:
// values.username:
// values.types:
changeFlagApi
(
values
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'编辑字典成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
else
{
createMessage
.
error
(
'编辑字典失败'
);
}
});
}
else
{
const
paramsAdd
=
{
dictName
:
values
.
dictName
,
dictType
:
values
.
dictType
,
flag
:
values
.
flag
,
remarks
:
values
.
remarks
,
dataId
:
values
.
dataId
,
parentId
:
values
.
parentId
,
createBy
:
values
.
createBy
,
createDate
:
values
.
createDate
,
updateBy
:
values
.
updateBy
,
updateDate
:
values
.
updateDate
,
delFlag
:
values
.
delFlag
,
businessId
:
values
.
businessId
,
dictSort
:
values
.
dictSort
,
remark
:
values
.
remark
,
username
:
values
.
username
,
types
:
values
.
types
,
};
addDict
(
paramsAdd
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'新增成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
});
}
}
finally
{
setModalProps
({
confirmLoading
:
false
});
}
}
</
script
>
src/views/system/dict/data/DictModal.vue
0 → 100644
View file @
63a8ea4b
<
template
>
<BasicModal
v-bind=
"$attrs"
@
register=
"registerModal"
:title=
"getTitle"
@
ok=
"handleSubmit"
>
<BasicForm
@
register=
"registerForm"
/>
</BasicModal>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
computed
,
unref
,
reactive
}
from
'vue'
;
import
{
BasicModal
,
useModalInner
}
from
'@/components/Modal'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
dictFormSchema
}
from
'./dictForm.data'
;
import
{
getDeptList
,
getAllRoleList
}
from
'@/api/demo/system'
;
import
{
addUserApi
,
UserDetailApi
,
UserUpdataApi
}
from
'@/api/system/dict/dicts'
;
import
{
addDict
,
addDataDict
,
changeFlagApi
,
changeDataFlagApi
,
DictDetailApi
,
DictDataDetailApi
,
}
from
'@/api/system/dict/dict'
;
import
{
encryptTwo
}
from
'../../../utils/jsencrypt.js'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
defineOptions
({
name
:
'DictModal'
});
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
{
createMessage
}
=
useMessage
();
const
isUpdate
=
ref
(
true
);
const
rowId
=
ref
(
''
);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const
[
registerForm
,
{
setFieldsValue
,
updateSchema
,
resetFields
,
validate
}]
=
useForm
({
labelWidth
:
100
,
baseColProps
:
{
span
:
24
},
schemas
:
dictFormSchema
,
showActionButtonGroup
:
false
,
actionColOptions
:
{
span
:
23
,
},
});
//初始化弹框
const
[
registerModal
,
{
setModalProps
,
closeModal
}]
=
useModalInner
(
async
(
data
)
=>
{
resetFields
();
setModalProps
({
confirmLoading
:
false
});
isUpdate
.
value
=
!!
data
?.
isUpdate
;
if
(
unref
(
isUpdate
))
{
// 获取行数据的id
console
.
log
(
data
,
'dictdata'
);
rowId
.
value
=
data
.
record
.
businessId
;
// 通过id获取行详情信息
DictDataDetailApi
(
rowId
.
value
).
then
((
res
)
=>
{
const
form
=
res
.
data
;
console
.
log
(
form
,
'dictdataform'
);
// 数据处理反显用户角色
// const roleData = res.data.roleIds.split(',');
// form.roleList = [];
// roleData.forEach((item) => {
// const id = Number(item);
// form.roleList.push(id);
// });
// 塞值
setFieldsValue
({
...
form
,
});
});
}
const
treeData
=
await
getDeptList
();
const
treeList
=
handleTree
(
treeData
.
data
,
'businessId'
,
undefined
,
undefined
,
undefined
);
updateSchema
([
{
field
:
'username'
,
show
:
!
unref
(
isUpdate
),
},
{
field
:
'password'
,
show
:
!
unref
(
isUpdate
),
},
{
field
:
'flag'
,
show
:
!
unref
(
isUpdate
),
},
{
field
:
'deptId'
,
componentProps
:
{
treeData
:
treeList
,
},
},
]);
});
const
getTitle
=
computed
(()
=>
(
!
unref
(
isUpdate
)
?
'新增字典数据'
:
'修改字典数据'
));
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
id
=
id
||
'id'
;
parentId
=
parentId
||
'parentId'
;
children
=
children
||
'children'
;
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
((
item
)
=>
{
return
item
[
parentId
];
}),
)
||
0
;
// 对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
// 循环所有项
const
treeData
=
cloneData
.
filter
((
father
)
=>
{
const
branchArr
=
cloneData
.
filter
((
child
)
=>
{
// 返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
];
});
branchArr
.
length
>
0
?
(
father
.
children
=
branchArr
)
:
''
;
// 返回第一层
return
father
[
parentId
]
===
rootId
;
});
return
treeData
!==
''
?
treeData
:
data
;
}
async
function
handleSubmit
()
{
try
{
const
values
=
await
validate
();
setModalProps
({
confirmLoading
:
true
});
console
.
log
(
values
);
console
.
log
(
rowId
,
'提交之前打印信息rowId'
);
// 编辑
if
(
unref
(
isUpdate
))
{
values
.
businessId
=
rowId
.
value
;
// values.remarks: 111
// values.createBy: 1
// values.createDate: 2024-10-17 15:34:32
// values.updateBy: 1
// values.updateDate: 2024-10-17 15:34:32
// values.delFlag: 0
// values.flag: 1
// values.businessId: 300
// values.dictType = rowId.value.dictType;
// values.dictName = rowId.value.dictName;
// values.parentId:
// values.dataId:
// values.dictSort:
// values.remark:
// values.username:
// values.types:
changeDataFlagApi
(
values
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'编辑字典成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
else
{
createMessage
.
error
(
'编辑字典失败'
);
}
});
}
else
{
const
paramsAdd
=
{
dictName
:
values
.
dictName
,
dictType
:
values
.
dictType
,
flag
:
values
.
flag
,
remarks
:
values
.
remarks
,
dataId
:
values
.
dataId
,
parentId
:
values
.
parentId
,
createBy
:
values
.
createBy
,
createDate
:
values
.
createDate
,
updateBy
:
values
.
updateBy
,
updateDate
:
values
.
updateDate
,
delFlag
:
values
.
delFlag
,
businessId
:
values
.
businessId
,
dictSort
:
values
.
dictSort
,
remark
:
values
.
remark
,
username
:
values
.
username
,
types
:
values
.
types
,
};
addDataDict
(
paramsAdd
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'新增成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
});
}
}
finally
{
setModalProps
({
confirmLoading
:
false
});
}
}
</
script
>
src/views/system/dict/data/dict.data.ts
0 → 100644
View file @
63a8ea4b
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
h
,
defineComponent
}
from
'vue'
;
import
{
Switch
}
from
'ant-design-vue'
;
// import { setRoleStatus } from '@/api/demo/system';
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
schemas
}
from
'@/views/demo/page/form/basic/data'
;
import
{
changeFlagApi
,
changeDataFlagApi
}
from
'@/api/system/dict/dict'
;
import
{
log
}
from
'vxe-pc-ui'
;
import
{
useRouter
}
from
'vue-router'
;
type
CheckedType
=
boolean
|
string
|
number
;
export
const
columns
:
BasicColumn
[]
=
[
{
title
:
'字典编码'
,
dataIndex
:
'businessId'
,
width
:
100
,
},
{
title
:
'字典标签'
,
dataIndex
:
'dictLabel'
,
width
:
100
,
},
// {
// title: '字典类型',
// dataIndex: 'dictType',
// width: 180,
// customRender: ({ record }) => {
// const router = useRouter(); // 获取路由实例
// return h(
// 'a', // 使用 <a> 标签实现点击跳转
// {
// style: { color: '#1890ff', cursor: 'pointer' }, // 设置样式
// onClick: () => {
// router.push({
// path: '/dict/type/data/' + record.businessId,
// query: {},
// });
// },
// },
// record.dictType,
// );
// },
// },
{
title
:
'字典键值'
,
dataIndex
:
'dictValue'
,
width
:
100
,
},
{
title
:
'字典排序'
,
dataIndex
:
'dictSort'
,
width
:
200
,
},
{
title
:
'状态'
,
dataIndex
:
'flag'
,
width
:
60
,
customRender
:
({
record
})
=>
{
if
(
!
Reflect
.
has
(
record
,
'pendingStatus'
))
{
record
.
pendingStatus
=
false
;
}
return
h
(
Switch
,
{
checked
:
record
.
flag
===
'1'
,
// checkedChildren: '停用',
// unCheckedChildren: '启用',
loading
:
record
.
pendingStatus
,
onChange
(
checked
:
CheckedType
)
{
record
.
pendingStatus
=
true
;
const
newStatus
=
checked
?
'1'
:
'0'
;
const
{
createMessage
}
=
useMessage
();
if
(
newStatus
===
'1'
)
{
record
.
flag
=
'1'
;
}
else
if
(
newStatus
===
'0'
)
{
record
.
flag
=
'0'
;
}
changeDataFlagApi
(
record
)
.
then
(()
=>
{
record
.
flag
=
newStatus
;
const
text
=
record
.
flag
===
'0'
?
'停用'
:
'启用'
;
createMessage
.
success
(
text
+
`成功`
);
})
.
catch
(()
=>
{
createMessage
.
error
(
'操作失败'
);
})
.
finally
(()
=>
{
record
.
pendingStatus
=
false
;
});
},
});
},
},
{
title
:
'备注'
,
dataIndex
:
'remarks'
,
width
:
150
,
},
{
title
:
'创建时间'
,
dataIndex
:
'createDate'
,
width
:
180
,
},
// {
// title: '操作',
// dataIndex: 'dictName',
// width: 200,
// },
];
export
const
searchFormSchema
:
FormSchema
[]
=
[
{
field
:
'dictName'
,
label
:
'字典名称'
,
component
:
'Input'
,
colProps
:
{
span
:
8
},
componentProps
:
{
disabled
:
true
,
},
},
{
field
:
'dictType'
,
label
:
'字典类型'
,
component
:
'Input'
,
colProps
:
{
span
:
8
},
},
{
field
:
'flag'
,
label
:
'状态'
,
component
:
'Select'
,
componentProps
:
{
options
:
[
{
label
:
'启用'
,
value
:
'1'
},
{
label
:
'停用'
,
value
:
'0'
},
],
},
colProps
:
{
span
:
8
},
},
// {
// field: 'createDate',
// label: '创建时间',
// component: 'RangePicker',
// componentProps: {
// format: 'YYYY-MM-DD', // 显示的日期格式
// valueFormat: 'YYYY-MM-DD', // 提交的日期格式
// placeholder: ['开始日期', '结束日期'], // 占位符
// style: { width: '300px' }, // 控制宽度
// },
// colProps: { span: 4 },
// },
{
field
:
'actions'
,
label
:
''
,
component
:
'Divider'
,
colProps
:
{
span
:
24
},
},
];
export
const
formSchema
:
FormSchema
[]
=
[
{
field
:
'dictName'
,
label
:
'字典名称'
,
required
:
true
,
component
:
'Input'
,
},
{
field
:
'dictType'
,
label
:
'字典类型'
,
required
:
true
,
component
:
'Input'
,
},
{
field
:
'flag'
,
label
:
'状态'
,
component
:
'RadioButtonGroup'
,
defaultValue
:
'0'
,
componentProps
:
{
options
:
[
{
label
:
'启用'
,
value
:
'1'
},
{
label
:
'停用'
,
value
:
'0'
},
],
},
},
{
label
:
'备注'
,
field
:
'remark'
,
component
:
'InputTextArea'
,
},
{
label
:
' '
,
field
:
'menu'
,
slot
:
'menu'
,
},
];
src/views/system/dict/data/dictForm.data.ts
0 → 100644
View file @
63a8ea4b
import
{
getAllRoleList
}
from
'@/api/demo/system'
;
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
optionsListApi
}
from
'@/api/demo/select'
;
import
{
h
}
from
'vue'
;
import
{
Tag
,
Switch
}
from
'ant-design-vue'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
changeFlagApi
,
changeDataFlagApi
}
from
'@/api/system/dict/dict'
;
// 引入开关组件
type
CheckedType
=
boolean
|
string
|
number
;
/**
* transform mock data
* {
* 0: '华东分部',
* '0-0': '华东分部-研发部'
* '0-1': '华东分部-市场部',
* ...
* }
*/
export
const
deptMap
=
(()
=>
{
const
pDept
=
[
'华东分部'
,
'华南分部'
,
'西北分部'
];
const
cDept
=
[
'研发部'
,
'市场部'
,
'商务部'
,
'财务部'
];
return
pDept
.
reduce
((
map
,
p
,
pIdx
)
=>
{
map
[
pIdx
]
=
p
;
cDept
.
forEach
((
c
,
cIndex
)
=>
(
map
[
`
${
pIdx
}
-
${
cIndex
}
`
]
=
`
${
p
}
-
${
c
}
`
));
return
map
;
},
{});
})();
export
const
dictFormSchema
:
any
[]
=
[
{
field
:
'dictType'
,
label
:
'字典类型'
,
component
:
'Input'
,
},
{
field
:
'dictLabel'
,
label
:
'参数标签'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入参数标签'
,
},
],
componentProps
:
{
maxLength
:
30
,
showCount
:
{
formatter
:
({
count
})
=>
`
${
count
}
/ 30`
,
},
},
},
{
field
:
'dictValue'
,
label
:
'参数键值'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入参数键值'
,
},
],
componentProps
:
{
maxLength
:
300
,
showCount
:
{
formatter
:
({
count
})
=>
`
${
count
}
/ 300`
,
},
},
},
{
field
:
'dictSort'
,
label
:
'参数排序'
,
component
:
'InputNumber'
,
rules
:
[
{
required
:
true
,
message
:
'请输入参数排序'
,
},
],
componentProps
:
{
min
:
0
,
// 最小值
step
:
1
,
// 控制每次增加或减少的数值
},
},
{
field
:
'remarks'
,
label
:
'备注'
,
component
:
'InputTextArea'
,
componentProps
:
{
maxLength
:
200
,
showCount
:
{
formatter
:
({
count
})
=>
`
${
count
}
/ 200`
,
},
},
},
];
src/views/system/dict/data/index.vue
0 → 100644
View file @
63a8ea4b
<
template
>
<div>
<BasicTable
@
register=
"registerTable"
>
<template
#
toolbar
>
<a-button
type=
"primary"
@
click=
"handleCreate"
>
新增
</a-button>
</
template
>
<
template
#
bodyCell=
"{ column, record }"
>
<template
v-if=
"column.key === 'action'"
>
<TableAction
:actions=
"[
{
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record),
},
{
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</
template
>
</template>
</BasicTable>
<DictModal
@
register=
"registerModal"
@
success=
"handleSuccess"
/>
</div>
</template>
<
script
lang=
"ts"
setup
>
import
{
BasicTable
,
useTable
,
TableAction
}
from
'@/components/Table'
;
import
{
getDictListByPage
,
deleteDict
,
getDictData
}
from
'@/api/demo/system'
;
import
{
useModal
}
from
'@/components/Modal'
;
import
DictModal
from
'./DictModal.vue'
;
import
{
columns
,
searchFormSchema
}
from
'./dict.data'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
useRoute
}
from
'vue-router'
;
import
{
onMounted
}
from
'vue'
;
defineOptions
({
name
:
'DictManagement'
});
// const [registerDrawer, { openDrawer }] = useDrawer();
const
route
=
useRoute
();
const
[
registerModal
,
{
openModal
}]
=
useModal
();
const
{
createMessage
}
=
useMessage
();
const
[
registerTable
,
{
reload
}]
=
useTable
({
title
:
'字典列表'
,
api
:
getDictData
,
columns
,
formConfig
:
{
labelWidth
:
100
,
schemas
:
searchFormSchema
,
showAdvancedButton
:
false
,
},
useSearchForm
:
true
,
showTableSetting
:
true
,
bordered
:
true
,
showIndexColumn
:
false
,
actionColumn
:
{
width
:
80
,
title
:
'操作'
,
dataIndex
:
'action'
,
// slots: { customRender: 'action' },
fixed
:
undefined
,
},
});
// 接受路由跳转传值{record}
// function handleCreate() {
// openDrawer(true, {
// isUpdate: false,
// });
// }
// function handleEdit(record: Recordable) {
// openDrawer(true, {
// record,
// isUpdate: true,
// });
// }
onMounted
(()
=>
{});
/** 新增按钮*/
function
handleCreate
()
{
openModal
(
true
,
{
isUpdate
:
false
,
});
}
/** 编辑按钮*/
function
handleEdit
(
record
:
Recordable
)
{
openModal
(
true
,
{
record
,
isUpdate
:
true
,
});
}
/** 删除按钮*/
function
handleDelete
(
record
:
Recordable
)
{
console
.
log
(
record
,
'删除执行前的数据'
);
deleteDict
({
id
:
record
.
businessId
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'删除成功'
);
reload
();
}
else
{
createMessage
.
success
(
'删除失败'
);
}
});
reload
();
}
function
handleSuccess
()
{
reload
();
}
</
script
>
src/views/system/dict/dict.data.ts
0 → 100644
View file @
63a8ea4b
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
h
,
defineComponent
}
from
'vue'
;
import
{
Switch
}
from
'ant-design-vue'
;
// import { setRoleStatus } from '@/api/demo/system';
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
schemas
}
from
'@/views/demo/page/form/basic/data'
;
import
{
changeFlagApi
}
from
'@/api/system/dict/dict'
;
import
{
log
}
from
'vxe-pc-ui'
;
import
{
useRouter
}
from
'vue-router'
;
import
page
from
'@/router/routes/modules/demo/page'
;
import
{
rowProps
}
from
'ant-design-vue/es/grid/Row'
;
type
CheckedType
=
boolean
|
string
|
number
;
export
const
columns
:
BasicColumn
[]
=
[
{
title
:
'序号'
,
dataIndex
:
'businessId'
,
width
:
50
,
},
{
title
:
'字典名称'
,
dataIndex
:
'dictName'
,
width
:
200
,
},
{
title
:
'字典类型'
,
dataIndex
:
'dictType'
,
width
:
180
,
customRender
:
({
record
})
=>
{
const
router
=
useRouter
();
// 获取路由实例
return
h
(
'a'
,
// 使用 <a> 标签实现点击跳转
{
style
:
{
color
:
'#1890ff'
,
cursor
:
'pointer'
},
// 设置样式
onClick
:
()
=>
{
router
.
push
({
path
:
'/dict/type/data/'
+
record
.
businessId
,
query
:
{},
state
:
{
record
},
// 通过 state 传递 record 对象到跳转目标页面
});
},
},
record
.
dictType
,
);
},
},
{
title
:
'状态'
,
dataIndex
:
'flag'
,
width
:
180
,
customRender
:
({
record
})
=>
{
if
(
!
Reflect
.
has
(
record
,
'pendingStatus'
))
{
record
.
pendingStatus
=
false
;
}
return
h
(
Switch
,
{
checked
:
record
.
flag
===
'1'
,
// checkedChildren: '停用',
// unCheckedChildren: '启用',
loading
:
record
.
pendingStatus
,
onChange
(
checked
:
CheckedType
)
{
record
.
pendingStatus
=
true
;
const
newStatus
=
checked
?
'1'
:
'0'
;
const
{
createMessage
}
=
useMessage
();
if
(
newStatus
===
'1'
)
{
record
.
flag
=
'1'
;
}
else
if
(
newStatus
===
'0'
)
{
record
.
flag
=
'0'
;
}
changeFlagApi
(
record
)
.
then
(()
=>
{
record
.
flag
=
newStatus
;
const
text
=
record
.
flag
===
'0'
?
'停用'
:
'启用'
;
createMessage
.
success
(
text
+
`成功`
);
})
.
catch
(()
=>
{
createMessage
.
error
(
'操作失败'
);
})
.
finally
(()
=>
{
record
.
pendingStatus
=
false
;
});
},
});
},
},
{
title
:
'备注'
,
dataIndex
:
'remark'
,
width
:
180
,
},
{
title
:
'创建时间'
,
dataIndex
:
'createDate'
,
width
:
180
,
},
];
export
const
searchFormSchema
:
FormSchema
[]
=
[
{
field
:
'dictName'
,
label
:
'字典名称'
,
component
:
'Input'
,
colProps
:
{
span
:
8
},
},
{
field
:
'dictType'
,
label
:
'字典类型'
,
component
:
'Input'
,
colProps
:
{
span
:
8
},
},
{
field
:
'flag'
,
label
:
'状态'
,
component
:
'Select'
,
componentProps
:
{
options
:
[
{
label
:
'启用'
,
value
:
'1'
},
{
label
:
'停用'
,
value
:
'0'
},
],
},
colProps
:
{
span
:
8
},
},
{
field
:
'createDate'
,
label
:
'创建时间'
,
component
:
'RangePicker'
,
componentProps
:
{
format
:
'YYYY-MM-DD'
,
// 显示的日期格式
valueFormat
:
'YYYY-MM-DD'
,
// 提交的日期格式
placeholder
:
[
'开始日期'
,
'结束日期'
],
// 占位符
style
:
{
width
:
'300px'
},
// 控制宽度
},
colProps
:
{
span
:
4
},
},
{
field
:
'actions'
,
label
:
''
,
component
:
'Divider'
,
colProps
:
{
span
:
16
},
},
];
export
const
formSchema
:
FormSchema
[]
=
[
{
field
:
'dictName'
,
label
:
'字典名称'
,
required
:
true
,
component
:
'Input'
,
},
{
field
:
'dictType'
,
label
:
'字典类型'
,
required
:
true
,
component
:
'Input'
,
},
{
field
:
'flag'
,
label
:
'状态'
,
component
:
'RadioButtonGroup'
,
defaultValue
:
'0'
,
componentProps
:
{
options
:
[
{
label
:
'启用'
,
value
:
'1'
},
{
label
:
'停用'
,
value
:
'0'
},
],
},
},
{
label
:
'备注'
,
field
:
'remark'
,
component
:
'InputTextArea'
,
},
{
label
:
' '
,
field
:
'menu'
,
slot
:
'menu'
,
},
];
src/views/system/dict/dictForm.data.ts
0 → 100644
View file @
63a8ea4b
import
{
getAllRoleList
}
from
'@/api/demo/system'
;
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
optionsListApi
}
from
'@/api/demo/select'
;
import
{
h
}
from
'vue'
;
import
{
Tag
,
Switch
}
from
'ant-design-vue'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
import
{
changeFlagApi
}
from
'@/api/system/dict/dict'
;
// 引入开关组件
type
CheckedType
=
boolean
|
string
|
number
;
/**
* transform mock data
* {
* 0: '华东分部',
* '0-0': '华东分部-研发部'
* '0-1': '华东分部-市场部',
* ...
* }
*/
export
const
deptMap
=
(()
=>
{
const
pDept
=
[
'华东分部'
,
'华南分部'
,
'西北分部'
];
const
cDept
=
[
'研发部'
,
'市场部'
,
'商务部'
,
'财务部'
];
return
pDept
.
reduce
((
map
,
p
,
pIdx
)
=>
{
map
[
pIdx
]
=
p
;
cDept
.
forEach
((
c
,
cIndex
)
=>
(
map
[
`
${
pIdx
}
-
${
cIndex
}
`
]
=
`
${
p
}
-
${
c
}
`
));
return
map
;
},
{});
})();
export
const
columns
:
BasicColumn
[]
=
[
// {
// title: '登录名',
// dataIndex: 'username',
// width: 120,
// },
// {
// title: '姓名',
// dataIndex: 'name',
// width: 120,
// },
// {
// title: '手机号',
// dataIndex: 'phone',
// width: 120,
// },
// {
// title: '状态',
// dataIndex: 'flag',
// width: 180,
// customRender: ({ record }) => {
// if (!Reflect.has(record, 'pendingStatus')) {
// record.pendingStatus = false;
// }
// return h(Switch, {
// checked: record.flag === '1',
// // checkedChildren: '停用',
// // unCheckedChildren: '启用',
// loading: record.pendingStatus,
// onChange(checked: CheckedType) {
// record.pendingStatus = true;
// const newStatus = checked ? '1' : '0';
// const { createMessage } = useMessage();
// const params = {
// businessId: record.businessId,
// flag: newStatus,
// };
// changeFlagApi(params)
// .then(() => {
// record.flag = newStatus;
// const text = record.flag === '1' ? '启用' : '停用';
// createMessage.success(text + `成功`);
// })
// .catch(() => {
// createMessage.error('操作失败');
// })
// .finally(() => {
// record.pendingStatus = false;
// });
// },
// });
// },
// },
// {
// title: '创建时间',
// dataIndex: 'createDate',
// width: 200,
// },
// {
// title: '所属部门',
// dataIndex: 'dept',
// customRender: ({ value }) => {
// return deptMap[value];
// },
// },
];
export
const
searchFormSchema
:
FormSchema
[]
=
[
{
field
:
'username'
,
label
:
'登录名'
,
component
:
'Input'
,
colProps
:
{
span
:
8
},
},
{
field
:
'flag'
,
label
:
'状态'
,
component
:
'Select'
,
componentProps
:
{
options
:
[
{
label
:
'启用'
,
value
:
'1'
},
{
label
:
'停用'
,
value
:
'0'
},
],
},
colProps
:
{
span
:
8
},
},
];
export
const
dictFormSchema
:
any
[]
=
[
{
field
:
'dictName'
,
label
:
'字典名称'
,
component
:
'Input'
,
// helpMessage: ['本字段演示异步验证', '不能输入带有admin的用户名'],
rules
:
[
{
required
:
true
,
message
:
'请输入字典名称'
,
},
// {
// trigger: 'blur',
// validator(_, value) {
// return new Promise((resolve, reject) => {
// if (!value) return resolve();
// isAccountExist(value)
// .then(resolve)
// .catch((err) => {
// reject(err.message || '验证失败');
// });
// });
// },
// },
],
},
{
field
:
'dictType'
,
label
:
'字典类型'
,
component
:
'Input'
,
rules
:
[
{
required
:
true
,
message
:
'请输入字典类型'
,
},
],
// ifShow: false,
},
{
field
:
'parentId'
,
label
:
'父字典名称'
,
component
:
'Select'
,
componentProps
:
{
options
:
[],
showActionButtonGroup
:
false
,
},
},
{
field
:
'remarks'
,
label
:
'备注'
,
component
:
'InputTextArea'
,
},
];
src/views/system/dict/index.vue
View file @
63a8ea4b
<
template
>
<div>
字典管理
<BasicTable
@
register=
"registerTable"
>
<template
#
toolbar
>
<a-button
type=
"primary"
@
click=
"handleCreate"
>
新增字典
</a-button>
</
template
>
<
template
#
bodyCell=
"{ column, record }"
>
<template
v-if=
"column.key === 'action'"
>
<TableAction
:actions=
"[
{
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record),
},
{
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</
template
>
</template>
</BasicTable>
<DictModal
@
register=
"registerModal"
@
success=
"handleSuccess"
/>
</div>
</template>
<
script
lang=
"ts"
setup
>
import
{
BasicTable
,
useTable
,
TableAction
}
from
'@/components/Table'
;
import
{
getDictListByPage
,
deleteDict
}
from
'@/api/demo/system'
;
import
{
useModal
}
from
'@/components/Modal'
;
import
DictModal
from
'./DictModal.vue'
;
import
{
columns
,
searchFormSchema
}
from
'./dict.data'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
</
script
>
defineOptions
({
name
:
'DictManagement'
});
// const [registerDrawer, { openDrawer }] = useDrawer();
const
[
registerModal
,
{
openModal
}]
=
useModal
();
const
{
createMessage
}
=
useMessage
();
const
[
registerTable
,
{
reload
}]
=
useTable
({
title
:
'字典列表'
,
api
:
getDictListByPage
,
columns
,
formConfig
:
{
labelWidth
:
100
,
schemas
:
searchFormSchema
,
showAdvancedButton
:
false
,
},
useSearchForm
:
true
,
showTableSetting
:
true
,
bordered
:
true
,
showIndexColumn
:
false
,
actionColumn
:
{
width
:
80
,
title
:
'操作'
,
dataIndex
:
'action'
,
// slots: { customRender: 'action' },
fixed
:
undefined
,
},
});
<
style
scoped
>
// function handleCreate() {
// openDrawer(true, {
// isUpdate: false,
// });
// }
</
style
>
// function handleEdit(record: Recordable) {
// openDrawer(true, {
// record,
// isUpdate: true,
// });
// }
/** 新增按钮*/
function
handleCreate
()
{
openModal
(
true
,
{
isUpdate
:
false
,
});
}
/** 编辑按钮*/
function
handleEdit
(
record
:
Recordable
)
{
openModal
(
true
,
{
record
,
isUpdate
:
true
,
});
}
/** 删除按钮*/
function
handleDelete
(
record
:
Recordable
)
{
console
.
log
(
record
,
'删除执行前的数据'
);
deleteDict
({
id
:
record
.
businessId
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'删除成功'
);
reload
();
}
else
{
createMessage
.
success
(
'删除失败'
);
}
});
reload
();
}
function
handleSuccess
()
{
reload
();
}
</
script
>
src/views/system/user/AccountModal.vue
View file @
63a8ea4b
...
...
@@ -4,18 +4,19 @@
</BasicModal>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
computed
,
unref
,
reactive
}
from
'vue'
;
import
{
ref
,
computed
,
unref
,
reactive
}
from
'vue'
;
import
{
BasicModal
,
useModalInner
}
from
'@/components/Modal'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
accountFormSchema
}
from
'./account.data'
;
import
{
getDeptList
}
from
'@/api/system/dept/dept'
;
import
{
addUserApi
,
UserDetailApi
,
UserUpdataApi
}
from
'@/api/system/user/user'
import
{
encryptTwo
}
from
'../../../../src/utils/jsencrypt.js'
import
{
addUserApi
,
UserDetailApi
,
UserUpdataApi
}
from
'@/api/system/dict/dict'
;
import
{
encryptTwo
}
from
'../../../../src/utils/jsencrypt.js'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
defineOptions
({
name
:
'AccountModal'
});
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
{
createMessage
}
=
useMessage
();
const
{
createMessage
}
=
useMessage
();
const
isUpdate
=
ref
(
true
);
const
rowId
=
ref
(
''
);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
...
...
@@ -38,28 +39,28 @@ const { createMessage } = useMessage();
// 获取行数据的id
rowId
.
value
=
data
.
record
.
businessId
;
// 通过id获取行详情信息
UserDetailApi
(
rowId
.
value
).
then
(
res
=>
{
const
form
=
res
.
data
UserDetailApi
(
rowId
.
value
).
then
(
(
res
)
=>
{
const
form
=
res
.
data
;
// 数据处理反显用户角色
if
(
res
.
data
.
roleIds
)
{
const
roleData
=
res
.
data
.
roleIds
.
split
(
','
)
form
.
roleList
=
[]
roleData
.
forEach
(
item
=>
{
const
id
=
Number
(
item
)
form
.
roleList
.
push
(
id
)
})
}
else
{
form
.
roleList
=
[]
if
(
res
.
data
.
roleIds
)
{
const
roleData
=
res
.
data
.
roleIds
.
split
(
','
)
;
form
.
roleList
=
[]
;
roleData
.
forEach
(
(
item
)
=>
{
const
id
=
Number
(
item
)
;
form
.
roleList
.
push
(
id
)
;
})
;
}
else
{
form
.
roleList
=
[]
;
}
// 塞值
setFieldsValue
({
...
form
,
});
})
})
;
}
const
treeData
=
await
getDeptList
();
const
treeList
=
handleTree
(
treeData
.
data
,
'businessId'
,
undefined
,
undefined
,
undefined
)
const
treeList
=
handleTree
(
treeData
.
data
,
'businessId'
,
undefined
,
undefined
,
undefined
);
updateSchema
([
{
field
:
'username'
,
...
...
@@ -76,7 +77,7 @@ const { createMessage } = useMessage();
{
field
:
'deptId'
,
componentProps
:
{
treeData
:
treeList
treeData
:
treeList
,
},
},
]);
...
...
@@ -85,23 +86,31 @@ const { createMessage } = useMessage();
const
getTitle
=
computed
(()
=>
(
!
unref
(
isUpdate
)
?
'新增账号'
:
'编辑账号'
));
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
id
=
id
||
'id'
parentId
=
parentId
||
'parentId'
children
=
children
||
'children'
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
(
item
=>
{
return
item
[
parentId
]
}))
||
0
id
=
id
||
'id'
;
parentId
=
parentId
||
'parentId'
;
children
=
children
||
'children'
;
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
((
item
)
=>
{
return
item
[
parentId
];
}),
)
||
0
;
// 对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
;
// 循环所有项
const
treeData
=
cloneData
.
filter
(
father
=>
{
const
branchArr
=
cloneData
.
filter
(
child
=>
{
const
treeData
=
cloneData
.
filter
(
(
father
)
=>
{
const
branchArr
=
cloneData
.
filter
(
(
child
)
=>
{
// 返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
]
})
branchArr
.
length
>
0
?
father
.
children
=
branchArr
:
''
return
father
[
id
]
===
child
[
parentId
]
;
})
;
branchArr
.
length
>
0
?
(
father
.
children
=
branchArr
)
:
''
;
// 返回第一层
return
father
[
parentId
]
===
rootId
})
return
treeData
!==
''
?
treeData
:
data
return
father
[
parentId
]
===
rootId
;
})
;
return
treeData
!==
''
?
treeData
:
data
;
}
async
function
handleSubmit
()
{
...
...
@@ -111,16 +120,16 @@ const { createMessage } = useMessage();
// TODO custom api
console
.
log
(
values
);
// 编辑
if
(
unref
(
isUpdate
))
{
values
.
businessId
=
rowId
.
value
UserUpdataApi
(
values
).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
if
(
unref
(
isUpdate
))
{
values
.
businessId
=
rowId
.
value
;
UserUpdataApi
(
values
).
then
(
(
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'编辑成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
})
}
else
{
})
;
}
else
{
const
paramsAdd
=
{
username
:
values
.
username
,
password
:
encryptTwo
(
values
.
password
),
...
...
@@ -133,15 +142,15 @@ const { createMessage } = useMessage();
flag
:
values
.
flag
,
deptId
:
values
.
deptId
,
roleList
:
values
.
roleList
,
remarks
:
values
.
remarks
}
addUserApi
(
paramsAdd
).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
remarks
:
values
.
remarks
,
}
;
addUserApi
(
paramsAdd
).
then
(
(
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'新增成功'
);
closeModal
();
emit
(
'success'
,
{
isUpdate
:
unref
(
isUpdate
),
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
})
})
;
}
}
finally
{
setModalProps
({
confirmLoading
:
false
});
...
...
src/views/system/user/DeptTree.vue
View file @
63a8ea4b
...
...
@@ -17,7 +17,7 @@
<
script
lang=
"ts"
setup
>
import
{
onMounted
,
ref
}
from
'vue'
;
import
{
BasicTree
,
TreeItem
}
from
'@/components/Tree'
;
import
{
getDeptList
}
from
'@/api/
system/dept/dept
'
;
import
{
getDeptList
}
from
'@/api/
demo/system
'
;
defineOptions
({
name
:
'DeptTree'
});
...
...
src/views/system/user/account.data.ts
View file @
63a8ea4b
import
{
getAllRoleList
}
from
'@/api/system/role/role'
;
import
{
getAllRoleList
}
from
'@/api/system/role/role'
;
import
{
BasicColumn
,
FormSchema
}
from
'@/components/Table'
;
import
{
h
}
from
"vue"
;
import
{
Tag
}
from
"ant-design-vue"
;
import
{
Switch
}
from
'ant-design-vu
e'
;
import
{
useMessage
}
from
"@/hooks/web/useMessage"
;
import
{
changeFlagApi
}
from
"@/api/system/user/user"
;
// 引入开关组件
import
{
h
}
from
'vue'
;
import
{
Tag
,
Switch
}
from
'ant-design-vue'
;
import
{
useMessage
}
from
'@/hooks/web/useMessag
e'
;
import
{
changeFlagApi
}
from
'@/api/system/dict/dicts'
;
// 引入开关组件
type
CheckedType
=
boolean
|
string
|
number
;
/**
* transform mock data
...
...
@@ -64,12 +64,12 @@ export const columns: BasicColumn[] = [
const
params
=
{
businessId
:
record
.
businessId
,
flag
:
newStatus
,
}
}
;
changeFlagApi
(
params
)
.
then
(()
=>
{
record
.
flag
=
newStatus
;
const
text
=
record
.
flag
===
'1'
?
'启用'
:
'停用'
createMessage
.
success
(
text
+
`成功`
);
const
text
=
record
.
flag
===
'1'
?
'启用'
:
'停用'
;
createMessage
.
success
(
text
+
`成功`
);
})
.
catch
(()
=>
{
// createMessage.error('操作失败');
...
...
@@ -126,7 +126,7 @@ export const resetPasswordFormSchema: any[] = [
required
:
true
,
// ifShow: false,
},
]
]
;
export
const
accountFormSchema
:
any
[]
=
[
{
field
:
'username'
,
...
...
@@ -164,13 +164,11 @@ export const accountFormSchema: any[] = [
field
:
'name'
,
label
:
'姓名'
,
component
:
'Input'
,
},
{
field
:
'nickName'
,
label
:
'昵称'
,
component
:
'Input'
,
},
{
field
:
'sex'
,
...
...
@@ -233,12 +231,11 @@ export const accountFormSchema: any[] = [
api
:
getAllRoleList
,
labelField
:
'roleName'
,
valueField
:
'businessId'
,
resultField
:
'data'
,
resultField
:
'data'
,
},
required
:
true
,
},
{
label
:
'备注'
,
field
:
'remarks'
,
...
...
src/views/system/user/importModal.vue
View file @
63a8ea4b
...
...
@@ -20,7 +20,7 @@ import { BasicModal, useModalInner } from '@/components/Modal';
import
{
BasicUpload
}
from
'@/components/Upload'
;
import
{
downloadByData
}
from
'@/utils/file/download'
;
import
{
Tag
,
Row
,
Col
,
Upload
,
Button
,
Checkbox
}
from
'ant-design-vue'
;
import
{
downImportTemplate
,
userImport
}
from
'@/api/system/
user/user
'
import
{
downImportTemplate
,
userImport
}
from
'@/api/system/
dict/dicts
'
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
defineOptions
({
name
:
'AccountModal'
});
...
...
src/views/system/user/index.vue
View file @
63a8ea4b
...
...
@@ -44,7 +44,7 @@
<
script
lang=
"ts"
setup
>
import
{
reactive
,
unref
}
from
'vue'
;
import
{
BasicTable
,
useTable
,
TableAction
}
from
'@/components/Table'
;
import
{
getAccountList
,
deleteUser
,
exportUserList
}
from
'@/api/system/
user/user
'
;
import
{
getAccountList
,
deleteUser
,
exportUserList
}
from
'@/api/system/
dict/dicts
'
;
import
{
PageWrapper
}
from
'@/components/Page'
;
import
DeptTree
from
'./DeptTree.vue'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
...
...
src/views/system/user/resetPassword.vue
View file @
63a8ea4b
<
template
>
<BasicModal
v-bind=
"$attrs"
@
register=
"registerModal"
:title=
"getTitle"
@
ok=
"handleSubmit"
minHeight=
"50"
>
<BasicModal
v-bind=
"$attrs"
@
register=
"registerModal"
:title=
"getTitle"
@
ok=
"handleSubmit"
minHeight=
"50"
>
<BasicForm
@
register=
"registerForm"
/>
</BasicModal>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
computed
,
unref
,
reactive
}
from
'vue'
;
import
{
BasicModal
,
useModalInner
}
from
'@/components/Modal'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
accountFormSchema
,
resetPasswordFormSchema
}
from
'./account.data'
;
import
{
getDeptList
}
from
'@/api/system/dept/dept'
;
import
{
resetUserPwd
}
from
'@/api/system/user/user'
import
{
encryptTwo
}
from
'../../../../src/utils/jsencrypt.js'
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
defineOptions
({
name
:
'AccountModal'
});
import
{
ref
,
computed
,
unref
,
reactive
}
from
'vue'
;
import
{
BasicModal
,
useModalInner
}
from
'@/components/Modal'
;
import
{
BasicForm
,
useForm
}
from
'@/components/Form'
;
import
{
accountFormSchema
,
resetPasswordFormSchema
}
from
'./account.data'
;
import
{
getDeptList
}
from
'@/api/system/dept/dept'
;
import
{
resetUserPwd
}
from
'@/api/system/dict/dicts'
;
import
{
encryptTwo
}
from
'../../../../src/utils/jsencrypt.js'
;
import
{
useMessage
}
from
'@/hooks/web/useMessage'
;
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
{
createMessage
}
=
useMessage
();
const
isUpdate
=
ref
(
true
);
const
rowId
=
ref
(
''
);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const
[
registerForm
,
{
setFieldsValue
,
updateSchema
,
resetFields
,
validate
}]
=
useForm
({
defineOptions
({
name
:
'AccountModal'
});
const
emit
=
defineEmits
([
'success'
,
'register'
]);
const
{
createMessage
}
=
useMessage
();
const
isUpdate
=
ref
(
true
);
const
rowId
=
ref
(
''
);
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const
[
registerForm
,
{
setFieldsValue
,
updateSchema
,
resetFields
,
validate
}]
=
useForm
({
labelWidth
:
100
,
baseColProps
:
{
span
:
24
},
schemas
:
resetPasswordFormSchema
,
...
...
@@ -28,18 +35,17 @@ const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] =
actionColOptions
:
{
span
:
23
,
},
});
//初始化弹框
const
[
registerModal
,
{
setModalProps
,
closeModal
}]
=
useModalInner
(
async
(
data
)
=>
{
});
//初始化弹框
const
[
registerModal
,
{
setModalProps
,
closeModal
}]
=
useModalInner
(
async
(
data
)
=>
{
resetFields
();
setModalProps
({
confirmLoading
:
false
});
rowId
.
value
=
data
.
record
.
businessId
;
});
const
getTitle
=
computed
(()
=>
(
'修改密码'
));
});
const
getTitle
=
computed
(()
=>
'修改密码'
);
async
function
handleSubmit
()
{
async
function
handleSubmit
()
{
try
{
const
values
=
await
validate
();
setModalProps
({
confirmLoading
:
true
});
...
...
@@ -47,17 +53,16 @@ async function handleSubmit() {
const
params
=
{
businessId
:
rowId
.
value
,
password
:
encryptTwo
(
values
.
newPassword
),
}
resetUserPwd
(
params
).
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
}
;
resetUserPwd
(
params
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
createMessage
.
success
(
'修改成功'
);
closeModal
();
emit
(
'success'
,
{
values
:
{
...
values
,
id
:
rowId
.
value
}
});
}
})
});
}
finally
{
setModalProps
({
confirmLoading
:
false
});
}
}
}
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment