Commit e950fa02 by zhangleyuan

feat:修改课程分类的编辑子分类

parent afe9fe10
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wufan * @Author: wufan
* @Date: 2020-11-25 18:25:02 * @Date: 2020-11-25 18:25:02
* @LastEditors: zhangleyuan * @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-04 11:11:50 * @LastEditTime: 2020-12-08 15:12:57
* @Description: Description * @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -37,7 +37,7 @@ export function deleteEmployee(params: object) { ...@@ -37,7 +37,7 @@ export function deleteEmployee(params: object) {
} }
export function getCourseCatalogList(params: object) { export function getCourseCatalogList(params: object) {
return Service.Hades("public/hades/getParentCategoryPage", params); return Service.Hades("public/hades/getCategoryPage", params);
} }
export function getAllSonCategory(params: object) { export function getAllSonCategory(params: object) {
......
...@@ -18,7 +18,7 @@ import "./CourseCatalogPage.less"; ...@@ -18,7 +18,7 @@ import "./CourseCatalogPage.less";
import User from '@/common/js/user'; import User from '@/common/js/user';
const { confirm } = Modal; const { confirm } = Modal;
interface RecordTypes { interface RecordTypes {
child: any; sonCategoryList: any;
} }
function CourseCatalogPage() { function CourseCatalogPage() {
...@@ -228,11 +228,13 @@ function CourseCatalogPage() { ...@@ -228,11 +228,13 @@ function CourseCatalogPage() {
listData.map((item:any,index:any) => { listData.map((item:any,index:any) => {
item.type = "parent" item.type = "parent"
item.key = item.id; item.key = item.id;
// item.child.map((_item:any,_index:any) =>{ if(item.sonCategoryList){
// _item.type = "child"; item.sonCategoryList.map((_item:any,_index:any) =>{
// _item.key=_item.id _item.type = "child";
// return _item _item.key=_item.id
// }); return _item
});
}
return item return item
}) })
return listData return listData
...@@ -264,8 +266,6 @@ function CourseCatalogPage() { ...@@ -264,8 +266,6 @@ function CourseCatalogPage() {
// return // return
// }); // });
// } // }
return ( return (
<div className=" page course-catalog-page"> <div className=" page course-catalog-page">
<div className="page-content"> <div className="page-content">
...@@ -285,23 +285,16 @@ function CourseCatalogPage() { ...@@ -285,23 +285,16 @@ function CourseCatalogPage() {
columns={ parseColumn() } columns={ parseColumn() }
pagination={false} pagination={false}
expandedRowRender={(record:RecordTypes) => { expandedRowRender={(record:RecordTypes) => {
if(!record.child){ if(!record.sonCategoryList){
return <div>还未添加任何子分类</div>; return <div>还未添加任何子分类</div>;
} }
if (record.child.length !== 0){ if (record.sonCategoryList.length !== 0){
return <Table columns={parseColumn()} dataSource={record.child} pagination={false} className="child-table"/> return <Table columns={parseColumn()} dataSource={record.sonCategoryList} pagination={false} className="child-table"/>
// return <div>{
// record.child.map((item:any,index:any)=>{
// return <span>{item.categoryName}</span>
// })
// }
// </div>
}else{ }else{
return <div>还未添加任何子分类</div>; return <div>还未添加任何子分类</div>;
} }
}} }}
dataSource={courseCatalogList} dataSource={courseCatalogList}
// onExpand={(expanded, record)=>expandSecondCatalog(expanded, record)}
/> />
</div> </div>
<div className="box-footer"> <div className="box-footer">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wufan * @Author: wufan
* @Date: 2020-11-27 16:21:49 * @Date: 2020-11-27 16:21:49
* @LastEditors: zhangleyuan * @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-08 14:12:20 * @LastEditTime: 2020-12-08 15:17:37
* @Description: Description * @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -20,6 +20,7 @@ interface CatalogAddOrEditModalProps { ...@@ -20,6 +20,7 @@ interface CatalogAddOrEditModalProps {
function CatalogAddOrEditModal(props: CatalogAddOrEditModalProps) { function CatalogAddOrEditModal(props: CatalogAddOrEditModalProps) {
const {onClose,modalType,refreshCatalogList,choosedItem} = props; const {onClose,modalType,refreshCatalogList,choosedItem} = props;
const [catalogName,setCatalogName] = useState(choosedItem.categoryName); const [catalogName,setCatalogName] = useState(choosedItem.categoryName);
useEffect(() => { useEffect(() => {
}); });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wufan * @Author: wufan
* @Date: 2020-11-27 16:21:49 * @Date: 2020-11-27 16:21:49
* @LastEditors: zhangleyuan * @LastEditors: zhangleyuan
* @LastEditTime: 2020-12-08 14:11:44 * @LastEditTime: 2020-12-08 15:34:07
* @Description: Description * @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -26,6 +26,7 @@ interface SecondCatalogAddOrEditModalProps { ...@@ -26,6 +26,7 @@ interface SecondCatalogAddOrEditModalProps {
function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) { function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) {
const {onClose,modalType,parentId,refreshCatalogList,choosedItem} = props; const {onClose,modalType,parentId,refreshCatalogList,choosedItem} = props;
console.log('choosedItem',choosedItem);
const [secondCatalogName,setSecondCatalogName] = useState(choosedItem.categoryName); const [secondCatalogName,setSecondCatalogName] = useState(choosedItem.categoryName);
const [selectParentId,setSelectParentId] = useState(parentId); const [selectParentId,setSelectParentId] = useState(parentId);
const [optionList,setOptionList] = useState([]); const [optionList,setOptionList] = useState([]);
...@@ -36,14 +37,32 @@ function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) { ...@@ -36,14 +37,32 @@ function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) {
}); });
useEffect(() => { useEffect(() => {
getOptionList(); getOptionList();
console.log('')
},[query]); },[query]);
function getOptionList():any { function getOptionList():any {
let _query = _.clone(query); let _query = _.clone(query);
_query.current = query.current + 1; _query.current = query.current + 1;
StoreService.getCourseCatalogList(_query).then((res: any) => { StoreService.getCourseCatalogList(_query).then((res: any) => {
setOptionList(res.result.records); let resultData = handleCatalogListData(res.result.records)
setOptionList(resultData);
}); });
} }
function handleCatalogListData(listData:any){
listData.map((item:any,index:any) => {
item.type = "parent"
item.key = item.id;
if(item.sonCategoryList){
item.sonCategoryList.map((_item:any,_index:any) =>{
_item.type = "child";
_item.key=_item.id
return _item
});
}
return item
})
return listData
}
function handleConfirm(){ function handleConfirm(){
if(modalType === "add"){ if(modalType === "add"){
addSecondcatalog(); addSecondcatalog();
...@@ -119,7 +138,7 @@ function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) { ...@@ -119,7 +138,7 @@ function SecondCatalogAddOrEditModal(props: SecondCatalogAddOrEditModalProps) {
placeholder="请输入子分类名称,最多10个字" placeholder="请输入子分类名称,最多10个字"
maxLength={10} maxLength={10}
style={{ width: 240 }} style={{ width: 240 }}
value={secondCatalogName} defaultValue={secondCatalogName}
onChange={(e) => { onChange={(e) => {
setSecondCatalogName(e.target.value); setSecondCatalogName(e.target.value);
}} }}
......
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