Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-resource
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-resource
Commits
cf5120a1
提交
cf5120a1
authored
6月 23, 2022
作者:
matian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:类别管理修改bug
上级
3f1b3100
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
39 行增加
和
27 行删除
+39
-27
api.ts
src/modules/admin/category/api.ts
+1
-1
AddDialog.vue
src/modules/admin/category/components/AddDialog.vue
+16
-9
TreeDialog.vue
src/modules/admin/category/components/TreeDialog.vue
+6
-1
List.vue
src/modules/admin/category/views/List.vue
+16
-16
没有找到文件。
src/modules/admin/category/api.ts
浏览文件 @
cf5120a1
...
...
@@ -28,6 +28,6 @@ export function delCategory(data: { id: string }) {
return
httpRequest
.
post
(
'/api/resource/v1/backend/category/delete'
,
data
)
}
// 移动分类
export
function
moveCategory
(
data
:
{
id
:
string
;
brother_id
:
string
;
type
:
'before'
|
'after'
})
{
export
function
moveCategory
(
data
:
{
id
:
string
;
brother_id
:
string
;
type
:
string
})
{
return
httpRequest
.
post
(
'/api/resource/v1/backend/category/drag'
,
data
)
}
src/modules/admin/category/components/AddDialog.vue
浏览文件 @
cf5120a1
<
script
lang=
"ts"
setup
>
import
{
createCategory
,
updateCategory
}
from
'../api'
import
{
createCategory
,
updateCategory
,
moveCategory
}
from
'../api'
import
{
ElMessage
}
from
'element-plus'
import
{
Search
}
from
'@element-plus/icons-vue'
...
...
@@ -17,8 +17,8 @@ const categoryForm = reactive({
parent_id
:
''
,
category_name
:
''
,
depth
:
1
,
status
:
'
0
'
,
need_pass
:
'
1
'
status
:
'
1
'
,
need_pass
:
'
0
'
})
const
rules
=
reactive
<
FormRules
>
({
category_name
:
[
...
...
@@ -78,13 +78,20 @@ const handleCancel = () => {
}
// 确认提交表单
const
handleConfirm
=
()
=>
{
console
.
log
(
props
.
isEdit
,
'00000'
)
console
.
log
(
props
.
isEdit
,
'00000'
,
categoryForm
)
if
(
props
.
isEdit
)
{
const
params
=
Object
.
assign
({
id
:
props
.
editData
.
id
},
categoryForm
)
updateCategory
(
params
).
then
(()
=>
{
ElMessage
.
success
(
'更新类别成功'
)
emit
(
'update:dialogVisible'
,
false
)
emit
(
'updatePage'
)
moveCategory
({
id
:
props
.
editData
.
id
,
brother_id
:
categoryForm
.
parent_id
,
type
:
'child'
}).
then
(()
=>
{
ElMessage
.
success
(
'更新类别成功'
)
emit
(
'update:dialogVisible'
,
false
)
emit
(
'updatePage'
)
})
})
}
else
{
const
params
=
Object
.
assign
({},
categoryForm
)
...
...
@@ -100,7 +107,7 @@ onMounted(() => {
console
.
log
(
props
.
editData
.
id
,
'0000'
)
categoryForm
.
depth
=
parseInt
(
props
.
editData
?.
depth
)
+
1
||
0
categoryForm
.
parent_id
=
props
.
editData
?.
id
categoryName
.
value
=
props
.
prevCategoryN
ame
categoryName
.
value
=
props
.
editData
.
category_n
ame
if
(
props
.
isEdit
)
{
categoryName
.
value
=
props
.
prevCategoryName
categoryForm
.
depth
=
props
.
editData
.
depth
...
...
@@ -114,10 +121,10 @@ onMounted(() => {
<el-dialog
:model-value=
"dialogVisible"
draggable
:before-close=
"handleCancel"
:title=
"props.title"
width=
"30%"
>
<el-form
:model=
"categoryForm"
label-position=
"right"
label-width=
"auto"
:rules=
"rules"
ref=
"formRef"
>
<el-form-item
label=
"上级类别:"
prop=
"parent_id"
>
<div
@
click=
"handleOpenTree"
style=
"width: 100%"
>
<div
style=
"width: 100%"
>
<el-input
v-model=
"categoryName"
disabled
>
<template
#
append
>
<el-button
:icon=
"Search"
/>
<el-button
:icon=
"Search"
@
click=
"handleOpenTree"
/>
</
template
>
</el-input>
</div>
...
...
src/modules/admin/category/components/TreeDialog.vue
浏览文件 @
cf5120a1
...
...
@@ -91,7 +91,6 @@ onMounted(() => {
@
node-click=
"handleNodeClick"
:filter-node-method=
"filterNode"
/>
<template
#
footer
>
<span>
<el-button
@
click=
"handleCancel"
>
取消
</el-button>
...
...
@@ -100,3 +99,9 @@ onMounted(() => {
</
template
>
</el-dialog>
</template>
<
style
lang=
"scss"
scoped
>
.filter-tree
{
height
:
40vh
;
overflow
:
auto
;
}
</
style
>
src/modules/admin/category/views/List.vue
浏览文件 @
cf5120a1
<
script
setup
lang=
"ts"
>
import
Sortable
from
'sortablejs'
import
type
{
MoveEvent
,
SortableEvent
}
from
'sortablejs'
import
type
{
SortableEvent
}
from
'sortablejs'
import
{
getCategoryList
,
delCategory
,
moveCategory
}
from
'../api'
import
{
ElMessage
,
ElMessageBox
}
from
'element-plus'
import
{
checkPermission
}
from
'@/utils/permission'
...
...
@@ -53,11 +53,11 @@ const handleAddRow = (row: ICategory) => {
dialogVisible
.
value
=
true
title
.
value
=
'新增类别'
editData
.
value
=
row
if
(
row
.
depth
>
'0'
)
{
prevCategoryName
.
value
=
getParent
(
row
.
id
,
tableData
[
0
]).
category_name
}
else
{
prevCategoryName
.
value
=
''
}
//
if (row.depth > '0') {
//
prevCategoryName.value = getParent(row.id, tableData[0]).category_name
//
} else {
//
prevCategoryName.value = ''
//
}
}
// // 外部新增类别
const
handleAddCategory
=
()
=>
{
...
...
@@ -132,16 +132,16 @@ function useSortable() {
Sortable
.
create
(
el
,
{
animation
:
300
,
onMove
(
evt
:
MoveEvent
)
{
const
dragged
=
evt
.
dragged
as
HTMLTableRowElement
const
related
=
evt
.
related
as
HTMLTableRowElement
const
draggedRow
=
tableDataList
[
dragged
.
rowIndex
]
const
relatedRow
=
tableDataList
[
related
.
rowIndex
]
// 禁止跨级拖拽
if
(
draggedRow
.
depth
!==
relatedRow
.
depth
||
draggedRow
.
pid
!==
relatedRow
.
pid
)
{
return
false
}
},
//
onMove(evt: MoveEvent) {
//
const dragged = evt.dragged as HTMLTableRowElement
//
const related = evt.related as HTMLTableRowElement
//
const draggedRow = tableDataList[dragged.rowIndex]
//
const relatedRow = tableDataList[related.rowIndex]
// 禁止跨级拖拽
//
if (draggedRow.depth !== relatedRow.depth || draggedRow.pid !== relatedRow.pid) {
//
return false
//
}
//
},
onEnd
(
evt
:
SortableEvent
)
{
const
{
oldIndex
,
newIndex
}
=
evt
if
(
oldIndex
===
undefined
||
newIndex
===
undefined
||
oldIndex
===
newIndex
)
return
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论