Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
b087a5a0
Commit
b087a5a0
authored
Dec 04, 2020
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:课程分类退出登录等进行接口联调
parent
31522557
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
501 additions
and
133 deletions
+501
-133
src/common/js/user.ts
+9
-3
src/data-source/base/request-apis.ts
+7
-4
src/data-source/store/request-apis.ts
+23
-0
src/domains/basic-domain/baseService.ts
+9
-5
src/domains/store-domain/storeService.ts
+28
-2
src/modules/personalInfo/index.tsx
+5
-12
src/modules/root/App.tsx
+10
-0
src/modules/root/Header.jsx
+70
-7
src/modules/root/Login.jsx
+4
-1
src/modules/root/Menu.tsx
+1
-1
src/modules/store-manege/CourseCatalogPage.tsx
+127
-98
src/modules/store-manege/modal/CatalogAddOrEditModal.less
+6
-0
src/modules/store-manege/modal/CatalogAddOrEditModal.tsx
+96
-0
src/modules/store-manege/modal/SecondCatalogAddOrEditModal.less
+6
-0
src/modules/store-manege/modal/SecondCatalogAddOrEditModal.tsx
+100
-0
No files found.
src/common/js/user.ts
View file @
b087a5a0
/*
* @Author: 吴文洁
* @Date: 2020-08-31 09:34:25
* @LastEditors:
wuf
an
* @LastEditTime: 2020-12-0
2 16:00:39
* @LastEditors:
zhangleyu
an
* @LastEditTime: 2020-12-0
4 11:37:33
* @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -43,7 +43,12 @@ class User {
setToken
(
value
:
any
)
{
return
Storage
.
set
(
`
${
PREFIX
}
_token`
,
value
);
}
removeToken
(){
return
Storage
.
remove
(
`
${
PREFIX
}
_token`
);
}
removeUserId
(){
return
Storage
.
remove
(
`
${
PREFIX
}
_userId`
);
}
}
export
default
new
User
();
\ No newline at end of file
src/data-source/base/request-apis.ts
View file @
b087a5a0
/*
* @Author: wufan
* @Date: 2020-12-01 17:21:21
* @LastEditors:
wuf
an
* @LastEditTime: 2020-12-0
2 15:56
:52
* @LastEditors:
zhangleyu
an
* @LastEditTime: 2020-12-0
4 11:42
:52
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -14,4 +14,8 @@ export function getUserStore(params: object) {
export
function
getUserPermission
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/getPermission"
,
params
);
}
\ No newline at end of file
}
export
function
logout
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/logout"
,
params
);
}
src/data-source/store/request-apis.ts
View file @
b087a5a0
/*
* @Author: wufan
* @Date: 2020-11-25 18:25:02
<<<<<<< Updated upstream
* @LastEditors: wufan
* @LastEditTime: 2020-12-04 10:52:49
=======
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 11:11:50
>>>>>>> Stashed changes
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -35,3 +40,21 @@ export function editEmployee(params: object) {
export
function
deleteEmployee
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/delStoreUser"
,
params
);
}
export
function
getCourseCatalogList
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/getParentCategoryPage"
,
params
);
}
export
function
getAllSonCategory
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/getAllSonCategory"
,
params
);
}
export
function
addCourseCategory
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/addCourseCategory"
,
params
);
}
export
function
editCourseCategory
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/editCourseCategory"
,
params
);
}
export
function
delCourseCategory
(
params
:
object
)
{
return
Service
.
Hades
(
"public/store/delCourseCategory"
,
params
);
}
src/domains/basic-domain/baseService.ts
View file @
b087a5a0
/*
* @Author: wufan
* @Date: 2020-12-01 17:20:49
* @LastEditors:
wuf
an
* @LastEditTime: 2020-12-0
1 17:23:45
* @LastEditors:
zhangleyu
an
* @LastEditTime: 2020-12-0
4 11:44:19
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import
{
getUserStore
,
getUserPermission
}
from
'@/data-source/base/request-apis'
;
import
{
getUserStore
,
getUserPermission
,
logout
}
from
'@/data-source/base/request-apis'
;
export
default
class
StoreService
{
// 获取员工列表
...
...
@@ -15,9 +15,12 @@ export default class StoreService {
return
getUserStore
(
params
);
}
// 获取员工列表
// 获取员工列表
static
getUserPermission
(
params
:
any
)
{
return
getUserPermission
(
params
);
}
//退出登录
static
logout
(
params
:
any
)
{
return
logout
(
params
);
}
}
\ No newline at end of file
src/domains/store-domain/storeService.ts
View file @
b087a5a0
/*
* @Author: wufan
* @Date: 2020-11-25 18:25:02
<<<<<<< Updated upstream
* @LastEditors: wufan
* @LastEditTime: 2020-12-04 10:52:26
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import
{
getEmployeeList
,
getUserList
,
getStoreDecorationList
,
getStoreRole
,
addEmployee
,
editEmployee
,
deleteEmployee
}
from
'@/data-source/store/request-apis'
;
=======
*
@
LastEditors
:
zhangleyuan
*
@
LastEditTime
:
2020
-
12
-
04
11
:
09
:
15
*
@
Description
:
Description
*
@@
Copyrigh
:
©
2020
杭州杰竞科技有限公司
版权所有
*
/
import
{
getEmployeeList
,
getUserList
,
getStoreDecorationList
,
getStoreRole
,
getCourseCatalogList
,
getAllSonCategory
,
addCourseCategory
,
delCourseCategory
,
editCourseCategory
}
from
'@/data-source/store/request-apis'
;
>>>>>>>
Stashed
changes
export
default
class
StoreService
{
// 获取员工列表
...
...
@@ -43,6 +52,22 @@ export default class StoreService {
static
getStoreDecorationList
(
params
:
any
)
{
return
getStoreDecorationList
(
params
);
}
// 获取课程分类列表
static
getCourseCatalogList
(
params
:
any
)
{
return
getCourseCatalogList
(
params
);
}
static
getAllSonCategory
(
params
:
any
)
{
return
getAllSonCategory
(
params
);
}
static
addCourseCategory
(
params
:
any
)
{
return
addCourseCategory
(
params
);
}
static
editCourseCategory
(
params
:
any
)
{
return
editCourseCategory
(
params
);
}
static
delCourseCategory
(
params
:
any
)
{
return
delCourseCategory
(
params
);
}
}
\ No newline at end of file
src/modules/personalInfo/index.tsx
View file @
b087a5a0
...
...
@@ -2,7 +2,7 @@
* @Author: zhangleyuan
* @Date: 2020-11-27 15:06:31
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-1
1-30 17:00:3
9
* @LastEditTime: 2020-1
2-04 14:57:5
9
* @Description: 描述一下
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -28,9 +28,7 @@ function PersonalInfoPage() {
const
[
cropperModalVisible
,
setCropperModalVisible
]
=
useState
(
false
);
const
[
IdentificationModalVisible
,
setIdentificationModalVisible
]
=
useState
(
false
);
const
[
changePhoneModalVisible
,
setChangePhoneModalVisible
]
=
useState
(
false
);
//Todo
const
[
phone
,
setPhone
]
=
useState
(
"18226927277"
);
const
[
phone
,
setPhone
]
=
useState
(
""
);
function
_handleUpdateAvatar
(
e
:
any
):
any
{
const
avatar
=
e
.
target
.
files
[
0
];
...
...
@@ -54,23 +52,18 @@ function PersonalInfoPage() {
}
function
identificationConfirm
():
any
{
setIdentificationModalVisible
(
false
);
console
.
log
(
'111'
);
setChangePhoneModalVisible
(
true
);
}
function
changePhoneModalConfirm
():
any
{
}
return
(
<
div
className=
"page personal-info-page"
>
<
div
className=
"page-content"
>
<
div
className=
"content-header"
>
<
Breadcrumbs
navList=
"个人设置"
goBack=
{
()
=>
{
window
.
RCHistory
.
goBack
();
}
}
/>
</
div
>
个人设置
</
div
>
<
div
className=
"box"
>
<
Form
>
<
div
className=
"avatat-item"
>
...
...
src/modules/root/App.tsx
View file @
b087a5a0
<<
<
<<<<
Updated
upstream
=======
/*
* @Author: 吴文洁
* @Date: 2019-07-10 10:30:49
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-02 19:47:15
* @Description:
*/
>
>>>>>>
Stashed changes
import React,
{
useContext
,
useEffect
}
from 'react';
import
{
withRouter
}
from 'react-router-dom';
import
{
ConfigProvider
}
from 'antd';
...
...
src/modules/root/Header.jsx
View file @
b087a5a0
/*
* @Author: 吴文洁
* @Date: 2019-09-10 18:26:03
* @LastEditors:
wangyixi
* @LastEditTime: 2020-1
1-11 14:04:50
* @LastEditors:
zhangleyuan
* @LastEditTime: 2020-1
2-04 15:09:25
* @Description:
*/
import
React
from
'react'
;
...
...
@@ -24,6 +24,9 @@ import {
}
from
'antd'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
Bus
from
'@/core/bus'
;
import
User
from
'@/common/js/user'
;
import
axios
from
'axios'
;
import
BaseService
from
"@/domains/basic-domain/baseService"
;
// var $topContainer = $('#top-container');
class
Header
extends
React
.
Component
{
constructor
(
props
)
{
...
...
@@ -32,11 +35,37 @@ class Header extends React.Component {
menuType
:
1
,
};
}
componentWillMount
()
{
}
componentDidMount
()
{
console
.
log
(
"ctx"
,
window
.
ctx
);
}
userMenu
()
{
const
style
=
{
whiteSpace
:
"normal"
,
wordBreak
:
"break-all"
};
return
(
<
Menu
style=
{
{
maxWidth
:
"250px"
,
marginTop
:
5
,
}
}
onClick=
{
e
=>
{
if
(
e
.
key
===
'1'
)
{
window
.
RCHistory
.
push
(
'/user_info'
);
Bus
.
trigger
(
'clearSearchText'
)
}
else
{
this
.
handleLogout
();
}
}
}
>
<
Menu
.
Item
style=
{
style
}
key=
"2"
>
退出登录
</
Menu
.
Item
>
</
Menu
>
);
}
handleMenu
=
()
=>
{
const
menuType
=
!
this
.
state
.
menuType
;
...
...
@@ -44,6 +73,29 @@ class Header extends React.Component {
Bus
.
trigger
(
'menuTypeChange'
,
menuType
);
});
};
handleLogout
()
{
// const AxiosInstance = axios.create({
// headers: {
// xmToken: User.getToken(),
// }
// });
// AxiosInstance.post('https://dev-heimdall.xiaomai5.com/hades/public/store/logout').then((res) => {
// User.removeUserId();
// User.removeToken();
// window.RCHistory.push({
// pathname: `/login`,
// })
// })
BaseService
.
logout
().
then
((
res
)
=>
{
User
.
removeUserId
();
User
.
removeToken
();
window
.
RCHistory
.
push
({
pathname
:
`/login`
,
})
});
}
render
()
{
const
{
}
=
this
.
state
;
...
...
@@ -68,8 +120,19 @@ class Header extends React.Component {
</
span
>
)
}
<
div
className=
"message-help"
>
<
Dropdown
>
<
Dropdown
overlay=
{
this
.
userMenu
()
}
>
<
div
className=
"user"
>
<
Avatar
style=
{
{
width
:
32
+
"px"
,
height
:
32
+
"px"
,
borderRadius
:
"50%"
,
overflow
:
"hidden"
,
flexShrink
:
0
,
}
}
size=
"large"
src=
"@/common/images/xiaomai-IMG.png"
/>
<
span
className=
"name"
>
张乐园
</
span
>
</
div
>
</
Dropdown
>
...
...
src/modules/root/Login.jsx
View file @
b087a5a0
...
...
@@ -68,7 +68,7 @@ function Login(props) {
setWaitStatus
(
false
)
clearTimeout
(
timer
);
}
else
{
setCodeText
(
`
${
waitTime
}
秒后重发`
)
setCodeText
(
`
${
waitTime
}
秒后重发`
)
setWaitStatus
(
true
)
timeSub
(
--
waitTime
,
1000
);
}
...
...
@@ -92,6 +92,9 @@ function Login(props) {
}
else
{
User
.
setUserId
(
data
.
result
.
userId
);
User
.
setToken
(
data
.
result
.
xmToken
);
window
.
RCHistory
.
push
({
pathname
:
`/personal-info`
,
})
}
})
}
...
...
src/modules/root/Menu.tsx
View file @
b087a5a0
...
...
@@ -35,7 +35,7 @@ function Aside(props: any) {
function
taggleMenu
(
item
:
any
)
{
window
.
RCHistory
.
push
(
item
.
link
)
}
function
onOpenChange
(
openKeys
:
string
[])
{
function
onOpenChange
(
openKeys
:
any
)
{
setOpenKeys
(
openKeys
)
}
return
(
...
...
src/modules/store-manege/CourseCatalogPage.tsx
View file @
b087a5a0
...
...
@@ -9,114 +9,77 @@ import React, { useEffect, useState } from "react";
import
{
withRouter
}
from
"react-router-dom"
;
import
_
from
"underscore"
;
import
PageControl
from
"@/components/PageControl"
;
import
{
CheckBox
}
from
"@/components"
;
import
{
Button
,
Table
,
Tooltip
,
Modal
,
message
,
Row
,
Col
,
Input
}
from
"antd"
;
import
{
Button
,
Table
,
Modal
,
message
}
from
"antd"
;
import
{
QuestionCircleOutlined
}
from
'@ant-design/icons'
;
import
StoreService
from
"@/domains/store-domain/storeService"
;
import
CatalogAddOrEditModal
from
'./modal/CatalogAddOrEditModal'
;
import
SecondCatalogAddOrEditModal
from
'./modal/SecondCatalogAddOrEditModal'
;
import
"./CourseCatalogPage.less"
;
import
User
from
'@/common/js/user'
;
const
{
confirm
}
=
Modal
;
const
{
Search
}
=
Input
;
declare
var
window
:
any
;
interface
RecordTypes
{
storeUserId
:
string
,
role
:
string
children
:
any
;
}
function
CourseCatalogPage
()
{
const
[
courseCatalogList
,
setCourseCatalogList
]
=
useState
([
{
key
:
1
,
name
:
'John Brown'
,
type
:
'parent'
,
children
:
[
{
key
:
11
,
name
:
'John Brown'
,
type
:
'child'
},
{
key
:
12
,
name
:
'John Brown'
,
type
:
'child'
}
]
},
{
key
:
2
,
name
:
'Jim Green'
,
type
:
'parent'
,
children
:
[
{
key
:
11
,
name
:
'John Brown'
,
type
:
'child'
},
{
key
:
12
,
name
:
'John Brown'
,
type
:
'child'
}
]
},
{
key
:
3
,
name
:
'Not Expandable'
,
type
:
'parent'
,
children
:
[
{
key
:
11
,
name
:
'John Brown'
,
type
:
'child'
},
{
key
:
12
,
name
:
'John Brown'
,
type
:
'child'
}
]
},
{
key
:
4
,
name
:
'Joe Black'
,
type
:
'parent'
,
children
:
[
{
key
:
11
,
name
:
'John Brown'
,
type
:
'child'
},
{
key
:
12
,
name
:
'John Brown'
,
type
:
'child'
}
]
},
]);
const
[
courseCatalogList
,
setCourseCatalogList
]
=
useState
([]);
const
[
query
,
setQuery
]
=
useState
({
current
:
0
,
size
:
10
,
name
:
""
,
phone
:
""
,
identity
:
"ALL"
,
instId
:
"1837447"
||
window
.
currentUserInstInfo
.
instId
,
storeId
:
User
.
getStoreId
(),
});
const
[
total
,
setTotal
]
=
useState
(
0
);
const
[
catalogModalVisible
,
setCatalogModalVisible
]
=
useState
(
false
);
const
[
catalogModalType
,
setCatalogModalType
]
=
useState
(
''
);
const
[
secondCatalogModalVisible
,
setSecondCatalogModalVisible
]
=
useState
(
false
);
const
[
secondCatalogModalType
,
setSecondCatalogModalType
]
=
useState
(
''
);
const
[
parentCatalogId
,
setParentCatalogId
]
=
useState
(
''
);
const
[
choosedItem
,
setChooseItem
]
=
useState
({});
useEffect
(()
=>
{
getCourseCatalogList
();
},
[
query
]);
function
addCatalog
(){
setChooseItem
({});
setCatalogModalVisible
(
true
)
;
setCatalogModalType
(
'add'
);
}
function
addSecondCatalog
(
record
:
any
){
setChooseItem
({});
setParentCatalogId
(
record
.
id
)
setSecondCatalogModalVisible
(
true
)
;
setSecondCatalogModalType
(
'add'
)
}
function
deleteCatalog
(
record
:
any
){
return
confirm
({
title
:
record
.
type
===
'parent'
?
'你确定要删除此分类吗?'
:
'你确定要删除此子分类吗?'
,
content
:
record
.
type
===
'parent'
?
'删除后,此分类下包含的所有子分类都会被删除,此操作不可恢复。'
:
'此操作不可恢复。'
,
icon
:
<
QuestionCircleOutlined
/>,
okText
:
'删除'
,
okType
:
'danger'
,
cancelText
:
'取消'
,
onOk
:
()
=>
{
handleDeleteCatalog
(
record
.
id
);
}
})
}
function
handleDeleteCatalog
(
categoryId
:
string
)
{
const
param
=
{
categoryId
}
StoreService
.
delCourseCategory
(
param
).
then
((
res
:
any
)
=>
{
message
.
success
(
"分类已删除"
);
getCourseCatalogList
();
});
}
function
parseColumn
():
any
{
return
[
{
title
:
'分类名称'
,
dataIndex
:
'n
ame'
,
key
:
'n
ame'
,
dataIndex
:
'categoryN
ame'
,
key
:
'categoryN
ame'
,
},
{
title
:
'操作'
,
...
...
@@ -130,6 +93,7 @@ function CourseCatalogPage() {
<>
<
span
className=
"add"
onClick=
{
()
=>
{
addSecondCatalog
(
record
)
}
}
>
添加子分类
</
span
>
...
...
@@ -138,13 +102,14 @@ function CourseCatalogPage() {
}
<
span
>
onClick=
{
()
=>
{
editCatalog
(
record
)}
}
>
编辑
</
span
>
<
span
className=
"divider-line"
>
{
" | "
}
</
span
>
<
span
<
span
className=
"divider-line"
>
{
" | "
}
</
span
>
<
span
onClick=
{
()
=>
{
deleteCatalog
(
record
)}
}
>
删除
删除
</
span
>
</
div
>
)
...
...
@@ -153,6 +118,61 @@ function CourseCatalogPage() {
},
]
}
function
getCourseCatalogList
():
any
{
let
_query
=
_
.
clone
(
query
);
_query
.
current
=
query
.
current
+
1
;
StoreService
.
getCourseCatalogList
(
_query
).
then
((
res
:
any
)
=>
{
let
resultData
=
handleCatalogListData
(
res
.
result
.
records
)
setCourseCatalogList
(
resultData
);
setTotal
(
res
.
result
.
total
);
});
}
function
handleCatalogListData
(
listData
:
any
){
listData
.
map
((
item
:
any
,
index
:
any
)
=>
{
item
.
type
=
"parent"
item
.
key
=
item
.
id
;
item
.
children
=
[];
return
item
})
return
listData
}
function
editCatalog
(
record
:
any
){
if
(
record
.
type
===
"parent"
){
setCatalogModalType
(
'edit'
);
setCatalogModalVisible
(
true
);
}
else
{
setSecondCatalogModalType
(
'edit'
);
setSecondCatalogModalVisible
(
true
);
}
setChooseItem
(
record
);
}
function
expandSecondCatalog
(
expanded
:
boolean
,
record
:
any
){
const
parentId
=
record
.
id
;
const
param
=
{
parentId
,
}
StoreService
.
getAllSonCategory
(
param
).
then
((
res
:
any
)
=>
{
handleSecondCatalogData
(
parentId
,
res
.
result
);
console
.
log
(
courseCatalogList
);
});
}
function
handleSecondCatalogData
(
parentId
:
any
,
listdata
:
any
){
listdata
.
map
((
item
:
any
,
index
:
any
)
=>
{
item
.
key
=
item
.
id
return
item
})
courseCatalogList
.
map
((
item
:
any
,
index
:
any
)
=>
{
if
(
item
.
id
===
parentId
){
item
.
children
=
listdata
;
}
return
item
})
setCourseCatalogList
(
courseCatalogList
)
}
return
(
<
div
className=
" page employee-manage-page"
>
<
div
className=
"page-content"
>
...
...
@@ -162,19 +182,25 @@ function CourseCatalogPage() {
<
Button
type=
"primary"
className=
"add-show-btn"
onClick=
{
()
=>
{
addCatalog
()}
}
>
添加分类
</
Button
>
</
div
>
<
div
className=
"box-body"
>
<
Table
columns=
{
parseColumn
()
}
pagination=
{
false
}
expandable=
{
{
rowExpandable
:
record
=>
record
.
name
!==
'还未添加子分类'
,
expandedRowRender=
{
(
record
:
RecordTypes
)
=>
{
if
(
record
.
children
.
length
!==
0
){
return
<
div
>
{
record
.
children
[
0
].
categoryName
}
</
div
>;
}
else
{
return
<
div
>
还未添加任何子分类
</
div
>;
}
}
}
dataSource=
{
courseCatalogList
}
onExpand=
{
(
expanded
,
record
)
=>
expandSecondCatalog
(
expanded
,
record
)
}
/>
</
div
>
<
div
className=
"box-footer"
>
...
...
@@ -188,9 +214,12 @@ function CourseCatalogPage() {
/>
</
div
>
</
div
>
{
/* {
isModalOpen && <EmployeeAddOrEditModal isOpen={isModalOpen} choosedItem={choosedItem} onClose={()=>{setIsModalOpen(false)}}/>
} */
}
{
catalogModalVisible
&&
<
CatalogAddOrEditModal
modalType=
{
catalogModalType
}
onClose=
{
()
=>
{
setCatalogModalVisible
(
false
)}
}
getCourseCatalogList=
{
()
=>
getCourseCatalogList
()
}
choosedItem=
{
choosedItem
}
/>
}
{
secondCatalogModalVisible
&&
<
SecondCatalogAddOrEditModal
modalType=
{
secondCatalogModalType
}
parentId=
{
parentCatalogId
}
onClose=
{
()
=>
{
setSecondCatalogModalVisible
(
false
)}
}
choosedItem=
{
choosedItem
}
/>
}
</
div
>
</
div
>
);
...
...
src/modules/store-manege/modal/CatalogAddOrEditModal.less
0 → 100644
View file @
b087a5a0
.catalog-add-edit-modal{
.ant-form-item-label > label{
color:#666;
}
}
\ No newline at end of file
src/modules/store-manege/modal/CatalogAddOrEditModal.tsx
0 → 100644
View file @
b087a5a0
/*
* @Author: wufan
* @Date: 2020-11-27 16:21:49
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 11:17:13
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
{
Modal
,
Form
,
Input
,
Button
}
from
"antd"
;
import
'./CatalogAddOrEditModal.less'
import
User
from
'@/common/js/user'
;
import
StoreService
from
"@/domains/store-domain/storeService"
;
interface
CatalogAddOrEditModalProps
{
onClose
:
any
;
modalType
:
string
getCourseCatalogList
:
any
;
choosedItem
:
any
;
}
function
CatalogAddOrEditModal
(
props
:
CatalogAddOrEditModalProps
)
{
const
{
onClose
,
modalType
,
getCourseCatalogList
,
choosedItem
}
=
props
;
console
.
log
(
"名称"
,
choosedItem
.
categoryName
);
const
[
catalogName
,
setCatalogName
]
=
useState
(
choosedItem
.
categoryName
);
console
.
log
(
"catalogName"
,
catalogName
);
useEffect
(()
=>
{
});
function
handleConfirm
(){
if
(
modalType
===
"add"
){
addCatalog
();
}
else
{
editCatalog
();
}
}
function
addCatalog
():
any
{
const
param
=
{
storeId
:
User
.
getStoreId
(),
categoryName
:
catalogName
}
StoreService
.
addCourseCategory
(
param
).
then
((
res
:
any
)
=>
{
onClose
();
getCourseCatalogList
();
});
}
function
editCatalog
():
any
{
const
param
=
{
categoryId
:
choosedItem
.
id
,
categoryName
:
catalogName
,
}
StoreService
.
editCourseCategory
(
param
).
then
((
res
:
any
)
=>
{
onClose
();
getCourseCatalogList
();
});
}
return
(
<
Modal
visible=
{
true
}
title=
{
modalType
===
"add"
?
'添加分类'
:
'编辑分类'
}
className=
"catalog-add-edit-modal"
onCancel=
{
onClose
}
width=
{
448
}
footer=
{
[
<
Button
id=
'cancel_allot_btn'
key=
"back"
onClick=
{
onClose
}
>
取消
</
Button
>,
<
Button
id=
'confirm_allot_btn'
key=
"submit"
type=
"primary"
onClick=
{
()
=>
{
handleConfirm
()
}
}
>
保存
</
Button
>
]
}
>
<
Form
labelCol=
{
{
span
:
5
}
}
>
<
Form
.
Item
label=
"分类名称"
name=
"分类名称"
rules=
{
[{
required
:
true
}]
}
>
<
Input
type=
"text"
placeholder=
"请输入子分类名称,最多10个字"
maxLength=
{
10
}
style=
{
{
width
:
240
}
}
defaultValue=
{
catalogName
}
onChange=
{
(
e
)
=>
{
setCatalogName
(
e
.
target
.
value
);
}
}
/>
</
Form
.
Item
>
</
Form
>
</
Modal
>
);
}
export
default
CatalogAddOrEditModal
;
src/modules/store-manege/modal/SecondCatalogAddOrEditModal.less
0 → 100644
View file @
b087a5a0
.second-catalog-add-edit-modal{
.ant-form-item-label > label{
color:#666;
}
}
\ No newline at end of file
src/modules/store-manege/modal/SecondCatalogAddOrEditModal.tsx
0 → 100644
View file @
b087a5a0
/*
* @Author: wufan
* @Date: 2020-11-27 16:21:49
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 10:40:57
* @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
{
Modal
,
Form
,
Input
,
Button
,
Select
}
from
"antd"
;
import
'./SecondCatalogAddOrEditModal.less'
import
User
from
'@/common/js/user'
;
import
StoreService
from
"@/domains/store-domain/storeService"
;
const
{
Option
}
=
Select
;
interface
SecondCatalogAddOrEditModalProps
{
onClose
:
(
e
:
any
)
=>
void
;
modalType
:
string
parentId
:
string
}
function
SecondCatalogAddOrEditModal
(
props
:
SecondCatalogAddOrEditModalProps
)
{
const
{
onClose
,
modalType
,
parentId
}
=
props
;
const
[
secondCatalogName
,
setSecondCatalogName
]
=
useState
(
''
);
useEffect
(()
=>
{
});
function
handleConfirm
(){
if
(
modalType
===
"add"
){
addSecondcatalog
();
}
}
function
addSecondcatalog
():
any
{
const
param
=
{
parentId
,
storeId
:
User
.
getStoreId
(),
categoryName
:
secondCatalogName
}
StoreService
.
addCourseCategory
(
param
).
then
((
res
:
any
)
=>
{
});
}
return
(
<
Modal
visible=
{
true
}
title=
{
modalType
===
"add"
?
'添加子分类'
:
'编辑子分类'
}
className=
"second-catalog-add-edit-modal"
onCancel=
{
onClose
}
width=
{
448
}
footer=
{
[
<
Button
id=
'cancel_allot_btn'
key=
"back"
onClick=
{
onClose
}
>
取消
</
Button
>,
<
Button
id=
'confirm_allot_btn'
key=
"submit"
type=
"primary"
onClick=
{
()
=>
{
handleConfirm
()
}
}
>
保存
</
Button
>
]
}
>
<
Form
labelCol=
{
{
span
:
6
}
}
>
<
Form
.
Item
label=
"子分类名称"
name=
"子分类名称"
rules=
{
[{
required
:
true
}]
}
>
<
Input
type=
"text"
placeholder=
"请输入子分类名称,最多10个字"
maxLength=
{
10
}
style=
{
{
width
:
240
}
}
onChange=
{
(
e
)
=>
{
setSecondCatalogName
(
e
.
target
.
value
);
}
}
/>
</
Form
.
Item
>
<
Form
.
Item
label=
"所属分类"
name=
"所属分类"
rules=
{
[{
required
:
true
}]
}
>
<
Select
style=
{
{
width
:
240
}
}
>
<
Option
value=
"china"
>
全部
</
Option
>
<
Option
value=
"usa"
>
一阶培训
</
Option
>
</
Select
>
</
Form
.
Item
>
</
Form
>
</
Modal
>
);
}
export
default
SecondCatalogAddOrEditModal
;
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