Commit b087a5a0 by zhangleyuan

feat:课程分类退出登录等进行接口联调

parent 31522557
/*
* @Author: 吴文洁
* @Date: 2020-08-31 09:34:25
* @LastEditors: wufan
* @LastEditTime: 2020-12-02 16:00:39
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 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
/*
* @Author: wufan
* @Date: 2020-12-01 17:21:21
* @LastEditors: wufan
* @LastEditTime: 2020-12-02 15:56:52
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 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);
}
/*
* @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);
}
/*
* @Author: wufan
* @Date: 2020-12-01 17:20:49
* @LastEditors: wufan
* @LastEditTime: 2020-12-01 17:23:45
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 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 {
// 获取员工列表
......@@ -19,5 +19,8 @@ export default class StoreService {
static getUserPermission(params: any) {
return getUserPermission(params);
}
//退出登录
static logout(params: any) {
return logout(params);
}
}
\ No newline at end of file
/*
* @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 {
// 获取员工列表
......@@ -44,5 +53,21 @@ export default class StoreService {
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
......@@ -2,7 +2,7 @@
* @Author: zhangleyuan
* @Date: 2020-11-27 15:06:31
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-11-30 17:00:39
* @LastEditTime: 2020-12-04 14:57:59
* @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,22 +52,17 @@ 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 className="box">
<Form>
......
<<<<<<< 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';
......
/*
* @Author: 吴文洁
* @Date: 2019-09-10 18:26:03
* @LastEditors: wangyixi
* @LastEditTime: 2020-11-11 14:04:50
* @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-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>
......
......@@ -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`,
})
}
})
}
......
......@@ -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 (
......
......@@ -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: 'name',
key: 'name',
dataIndex: 'categoryName',
key: 'categoryName',
},
{
title: '操作',
......@@ -130,6 +93,7 @@ function CourseCatalogPage() {
<>
<span
className="add"
onClick={() => { addSecondCatalog(record) }}
>
添加子分类
</span>
......@@ -138,11 +102,12 @@ function CourseCatalogPage() {
}
<span
onClick={()=>{editCatalog(record)}}
>
编辑
</span>
<span className="divider-line">{" | "}</span>
<span
<span className="divider-line" >{" | "}</span>
<span onClick={()=>{deleteCatalog(record)}}
>
删除
</span>
......@@ -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>
);
......
.catalog-add-edit-modal{
.ant-form-item-label > label{
color:#666;
}
}
\ No newline at end of file
/*
* @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;
.second-catalog-add-edit-modal{
.ant-form-item-label > label{
color:#666;
}
}
\ No newline at end of file
/*
* @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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment