Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
admin
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
admin
Commits
248c88a7
提交
248c88a7
authored
6月 12, 2023
作者:
ZhangLingKun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
功能:课程问题修复
上级
4f04636a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
116 行增加
和
36 行删除
+116
-36
mallManageType.ts
src/api/interface/mallManageType.ts
+15
-11
mallManage.ts
src/api/modules/mallManage.ts
+5
-0
index.tsx
...pages/mallManage/courseManage/comp/addEditModal/index.tsx
+26
-23
index.tsx
src/pages/mallManage/courseManage/index.tsx
+36
-2
getTreeIds.ts
src/utils/getTreeIds.ts
+34
-0
没有找到文件。
src/api/interface/mallManageType.ts
浏览文件 @
248c88a7
...
...
@@ -20,17 +20,21 @@ export type queryCurriculumInfoListType = InterListFunction<
supplierName
:
string
;
surfaceUrl
:
null
;
videoUrl
:
string
;
categoriesId
:
number
;
directoryName
:
null
;
categoriesName
:
null
;
}
>
;
// V1.0.1新增课程
export
type
addCurriculumType
=
InterFunction
<
{
categoriesId
?:
number
;
categoriesName
?:
string
;
curriculumDesc
?:
string
;
curriculumName
?:
string
;
detailContent
?:
string
;
directoryName
?:
string
;
flightSkills
?:
number
;
flightSkillsName1
?:
string
;
flightSkillsName2
?:
string
;
free
?:
number
;
id
?:
number
|
null
;
price
?:
number
;
...
...
@@ -79,16 +83,16 @@ export type queryCategoryInfoByType = InterFunction<
/**
* 类型:1:作业服务 2:设备 3:培训 4:产品商城
*/
type
:
number
type
:
number
;
},
{
directoryId
:
number
name
:
string
directoryId
:
number
;
name
:
string
;
categoriesInfoListDTO
:
Array
<
{
id
:
number
directoryId
:
number
name
:
string
icon
:
string
}
>
id
:
number
;
directoryId
:
number
;
name
:
string
;
icon
:
string
;
}
>
;
}[]
>
>
;
src/api/modules/mallManage.ts
浏览文件 @
248c88a7
import
axios
from
'~/api/request'
;
import
{
addCurriculumType
,
queryCategoryInfoByType
,
queryCurriculumInfoListType
,
removeCurriculumType
,
treeCurriculumSkillType
,
...
...
@@ -23,4 +24,8 @@ export class MallManageAPI {
// V1.0.1删除课程
static
removeCurriculum
:
removeCurriculumType
=
(
params
)
=>
axios
.
get
(
'/release/curriculum/removeCurriculum'
,
{
params
});
// 根据类型获取各个目录及分类信息
static
queryCategoryInfoByType
:
queryCategoryInfoByType
=
(
params
)
=>
axios
.
get
(
'/pms/classify/queryCategoryInfoByType'
,
{
params
});
}
src/pages/mallManage/courseManage/comp/addEditModal/index.tsx
浏览文件 @
248c88a7
...
...
@@ -65,6 +65,7 @@ const AddEditModal: React.FC<propType> = (props) => {
const
res
=
await
MallManageAPI
[
data
?.
id
?
'updateCurriculum'
:
'addCurriculum'
]({
...
values
,
flightSkills
:
Number
((
values
?.
flightSkills
as
unknown
as
number
[])?.
at
(
-
1
)),
categoriesId
:
Number
((
values
?.
flightSkills
as
unknown
as
number
[])?.
at
(
-
1
)),
id
:
data
?.
id
?
data
?.
id
:
null
,
});
if
(
res
&&
res
.
code
===
'200'
)
{
...
...
@@ -74,38 +75,40 @@ const AddEditModal: React.FC<propType> = (props) => {
};
// 获取课程类型
const
getCurriculumSkillList
=
async
()
=>
{
const
res
=
await
MallManageAPI
.
treeCurriculumSkill
({});
const
res
=
await
MallManageAPI
.
queryCategoryInfoByType
({
type
:
3
,
});
if
(
res
&&
res
.
code
===
'200'
)
{
setCurriculumSkillList
(
res
.
result
?.
map
((
i
)
=>
({
label
:
i
.
skillsName
,
value
:
i
.
id
,
children
:
i
.
flightSkills
?.
map
((
j
)
=>
({
label
:
j
.
skillsName
,
value
:
j
.
id
})),
})),
);
// console.log(res);
}
};
// componentDidMount
useEffect
(()
=>
{
if
(
!
open
)
return
;
// 获取课程类型
getCurriculumSkillList
().
then
(()
=>
{
const
arr
=
res
.
result
?.
filter
((
i
)
=>
i
.
categoriesInfoListDTO
)
.
map
((
i
)
=>
({
label
:
i
.
name
,
value
:
i
.
directoryId
,
children
:
i
.
categoriesInfoListDTO
?.
map
((
j
)
=>
({
label
:
j
.
name
,
value
:
j
.
id
})),
}));
setCurriculumSkillList
(
arr
);
// 回显数据
// 回显数据
// 回显数据
// 加载出数据再操作
if
(
!
data
)
return
;
// console.log(data);
// 反向找数据回显
const
flightSkillsName1
=
curriculumSkillList
.
find
(
(
i
)
=>
i
.
label
===
data
?.
flightSkillsName1
,
);
const
flightSkillsName2
=
flightSkillsName1
?.
children
?.
find
(
(
i
)
=>
i
.
label
===
data
?.
flightSkillsName2
,
const
flightSkillsName1
=
arr
?.
find
((
i
)
=>
i
.
children
?.
find
((
j
)
=>
j
.
value
===
data
?.
categoriesId
),
);
// 回显数据
form
.
setFieldsValue
({
...
data
,
flightSkills
:
[
flightSkillsName1
?.
value
,
flightSkillsName2
?.
value
],
flightSkills
:
[
flightSkillsName1
?.
value
,
data
?.
categoriesId
],
});
});
}
};
// componentDidMount
useEffect
(()
=>
{
if
(
!
open
)
return
;
// 获取课程类型
getCurriculumSkillList
().
then
();
},
[
open
]);
return
(
<
Modal
...
...
src/pages/mallManage/courseManage/index.tsx
浏览文件 @
248c88a7
...
...
@@ -17,6 +17,17 @@ let query: ReqType = {};
const
CourseManageView
=
()
=>
{
const
{
confirm
}
=
Modal
;
// 课程类型列表
const
[
curriculumSkillList
,
setCurriculumSkillList
]
=
useState
<
{
value
:
number
;
label
:
string
;
children
?:
Array
<
{
value
:
number
;
label
:
string
;
}
>
;
}[]
>
([]);
// 是否打开变更弹窗
const
[
isAddEditVisModal
,
setIsAddEditVisModal
]
=
useState
<
boolean
>
(
false
);
// 表格分页配置
...
...
@@ -78,6 +89,23 @@ const CourseManageView = () => {
},
});
};
// 获取课程类型
const
getCurriculumSkillList
=
async
()
=>
{
const
res
=
await
MallManageAPI
.
queryCategoryInfoByType
({
type
:
3
,
});
if
(
res
&&
res
.
code
===
'200'
)
{
setCurriculumSkillList
(
res
.
result
?.
filter
((
i
)
=>
i
.
categoriesInfoListDTO
)
.
map
((
i
)
=>
({
label
:
i
.
name
,
value
:
i
.
directoryId
,
children
:
i
.
categoriesInfoListDTO
?.
map
((
j
)
=>
({
label
:
j
.
name
,
value
:
j
.
id
})),
})),
);
}
};
// 表格结构
const
columns
:
ColumnsType
<
TableType
[
0
]
>
=
[
{
...
...
@@ -88,10 +116,15 @@ const CourseManageView = () => {
},
{
title
:
'课程类型'
,
dataIndex
:
'
flightSkillsName1
'
,
dataIndex
:
'
categoriesId
'
,
align
:
'center'
,
width
:
'150px'
,
render
:
(
text
,
record
)
=>
`
${
text
}
/
${
record
.
flightSkillsName2
}
`
,
render
:
(
text
)
=>
{
// 反向找数据回显
const
item
=
curriculumSkillList
.
find
((
i
)
=>
i
.
children
?.
find
((
j
)
=>
j
.
value
===
text
));
const
childrenItem
=
item
?.
children
?.
find
((
i
)
=>
i
.
value
===
text
);
return
`
${
item
?.
label
}
/${childrenItem
?
.label}`
;
},
},
{
title
:
'课程类型'
,
...
...
@@ -143,6 +176,7 @@ const CourseManageView = () => {
useEffect
(()
=>
{
query
=
{};
(
async
()
=>
{
await
getCurriculumSkillList
();
await
getTableList
();
})();
},
[]);
...
...
src/utils/getTreeIds.ts
0 → 100644
浏览文件 @
248c88a7
// 通过子节点找到整个树
export
const
getTreeIds
=
(
tree
:
any
[],
nodeId
:
number
,
config
?:
{
children
:
string
;
id
:
string
},
)
=>
{
const
{
children
=
'children'
,
id
=
'id'
}
=
config
||
{};
// 先拍平数组
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const
toFlatArray
=
(
treeArr
:
any
[],
parentId
?:
any
)
=>
{
return
treeArr
.
reduce
((
t
,
_
)
=>
{
const
child
=
_
[
children
];
return
[
...
t
,
parentId
?
{
...
_
,
parentId
}
:
_
,
...(
child
&&
child
.
length
?
toFlatArray
(
child
,
_
[
id
])
:
[]),
];
},
[]);
};
// 找到所有的id
const
getIds
=
(
flatArray
:
any
[])
=>
{
let
ids
=
[
nodeId
];
let
child
=
flatArray
.
find
((
_
)
=>
_
[
id
]
===
nodeId
);
while
(
child
&&
child
.
parentId
)
{
ids
=
[
child
.
parentId
,
...
ids
];
// eslint-disable-next-line no-loop-func
child
=
flatArray
.
find
((
_
)
=>
_
[
id
]
===
child
.
parentId
);
}
return
ids
;
};
// 返回找到的数据
return
getIds
(
toFlatArray
(
tree
));
};
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论