Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tea-resources-web
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
tea-resources-web
Commits
be15b5e5
Commit
be15b5e5
authored
Mar 30, 2024
by
YLKCNK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner管理
parent
0bb26d00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
574 additions
and
0 deletions
+574
-0
cmsBanner.js
src/api/contentManagement/cmsBanner.js
+68
-0
index.vue
src/views/contentManagement/banner/index.vue
+506
-0
No files found.
src/api/contentManagement/cmsBanner.js
0 → 100644
View file @
be15b5e5
import
request
from
'@/utils/request'
import
Qs
from
'qs'
/**
* 1. 列表查询
* 2. 查询详细信息
* 3. 新增
* 4. 修改
* 5. 逻辑删除
* 6. 导出
*
*/
// 1. 查询banner管理列表
export
function
listCmsBanner
(
query
)
{
return
request
({
url
:
'/cmsbanner/queryCmsBannerByPagination'
,
method
:
'get'
,
params
:
query
})
}
// 2. 查询banner管理详细信息
export
function
getCmsBanner
(
businessId
)
{
return
request
({
url
:
'/cmsbanner/detail/'
+
businessId
,
method
:
'get'
})
}
// 3. 新增banner管理
export
function
addCmsBanner
(
data
)
{
data
=
Qs
.
stringify
(
data
)
return
request
({
url
:
'/cmsbanner/add'
,
method
:
'post'
,
data
:
data
})
}
// 4. 修改banner管理
export
function
updateCmsBanner
(
data
)
{
const
businessId
=
data
.
businessId
data
=
Qs
.
stringify
(
data
)
return
request
({
url
:
'/cmsbanner/update/'
+
businessId
,
method
:
'put'
,
data
})
}
// 5. 逻辑删除banner管理
export
function
delCmsBanner
(
businessId
)
{
return
request
({
url
:
'/cmsbanner/deleteLogical/'
+
businessId
,
method
:
'delete'
})
}
// 6. 导出banner管理
export
function
exportCmsBanner
(
query
)
{
return
request
({
url
:
'/cmsbanner/export'
,
method
:
'get'
,
params
:
query
,
responseType
:
'blob'
})
}
src/views/contentManagement/banner/index.vue
0 → 100644
View file @
be15b5e5
<
template
>
<div
class=
"app-container"
>
<el-form
ref=
"queryForm"
style=
"padding: 0 0 0 10px"
:model=
"queryParams"
:inline=
"true"
>
<el-form-item
label=
"名称"
prop=
"bannerName"
>
<el-input
v-model=
"queryParams.bannerName"
placeholder=
"请输入名称"
clearable
:maxlength=
"500"
size=
"small"
style=
"width: 150px"
/>
</el-form-item>
<el-form-item
label=
"链接地址"
prop=
"linkUrl"
>
<el-input
v-model=
"queryParams.linkUrl"
placeholder=
"请输入链接地址"
clearable
:maxlength=
"255"
size=
"small"
style=
"width: 150px"
/>
</el-form-item>
<el-form-item>
<el-button
:class=
"commonField.queryClass"
:type=
"commonField.typePrimary"
:icon=
"commonField.queryIcon"
:size=
"commonField.smallSize"
@
click=
"handleQuery"
>
查询
</el-button>
<el-button
:class=
"commonField.resetClass"
:icon=
"commonField.resetIcon"
:size=
"commonField.smallSize"
@
click=
"resetQuery"
>
重置
</el-button>
</el-form-item>
<div
style=
"float: right"
>
<el-form-item>
<el-button
:class=
"commonField.addClass"
:type=
"commonField.typePrimary"
:icon=
"commonField.addIcon"
:size=
"commonField.smallSize"
@
click=
"handleAdd"
>
新增
</el-button>
</el-form-item>
</div>
</el-form>
<div
class=
"placeholder"
/>
<div
style=
"padding:5px 10px"
>
<el-table
v-loading=
"loading"
border
:data=
"cmsBannerList"
>
<el-table-column
label=
"分类"
prop=
"type"
:show-overflow-tooltip=
"true"
width=
"130px"
>
<template
slot-scope=
"scope"
>
<span
v-if=
"scope.row.type=='0'"
>
课程资源
</span>
<span
v-else-if=
"scope.row.type=='1'"
>
其他资源
</span>
<span
v-else
>
-
</span>
</
template
>
</el-table-column>
<el-table-column
label=
"名称"
prop=
"bannerName"
:show-overflow-tooltip=
"true"
width=
"130px"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
bannerName
||
'-'
}}
</
template
>
</el-table-column>
<!-- <el-table-column label="图片" prop="bannerPicture" :show-overflow-tooltip="true">-->
<!-- <template slot-scope="scope">-->
<!-- {{ scope.row.bannerPicture || '-' }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
label=
"图片"
prop=
"bannerPicture"
:show-overflow-tooltip=
"true"
width=
"150px"
>
<
template
slot-scope=
"scope"
>
<div
:id=
"step(scope.$index)"
>
<el-image
style=
"width:100%;height:100%;"
:src=
"imagePath+scope.row.url"
:preview-src-list=
"[imagePath+scope.row.url]"
@
click=
"handleClickStop(scope.$index)"
@
mouseover=
"justEnter($event)"
@
mouseout=
"justOut($event)"
>
<div
slot=
"error"
class=
"image-slot"
>
<i
class=
"el-icon-picture-outline"
/>
</div>
</el-image>
</div>
</
template
>
</el-table-column>
<el-table-column
label=
"链接地址"
prop=
"linkUrl"
:show-overflow-tooltip=
"true"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
linkUrl
||
'-'
}}
</
template
>
</el-table-column>
<el-table-column
label=
"排序号"
prop=
"weight"
:show-overflow-tooltip=
"true"
width=
"80px"
>
<
template
slot-scope=
"scope"
>
{{
scope
.
row
.
weight
||
'-'
}}
</
template
>
</el-table-column>
<el-table-column
width=
"120"
label=
"状态"
prop=
"flag"
>
<
template
slot-scope=
"scope"
>
<el-switch
v-model=
"scope.row.flag"
class=
"switchDisabledStyle"
inactive-value=
"0"
active-value=
"1"
@
click
.
native=
"handleStatusChange(scope.row)"
/>
</
template
>
</el-table-column>
<!-- <el-table-column label="备注" prop="remarks" :show-overflow-tooltip="true">-->
<!-- <template slot-scope="scope">-->
<!-- {{ scope.row.remarks || '-' }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="创建时间" prop="createDate" :show-overflow-tooltip="true">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ scope.row.createDate | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
label=
"操作"
class-name=
"small-padding fixed-width"
width=
"200px"
>
<
template
slot-scope=
"scope"
>
<el-button
:class=
"commonField.updateClass"
:type=
"commonField.typeParent"
:size=
"commonField.size"
@
click=
"handleUpdate(scope.row)"
>
修改
</el-button>
<el-button
:class=
"commonField.delClass"
:type=
"commonField.typeParent"
:size=
"commonField.size"
@
click=
"handleDelete(scope.row)"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
</div>
<pagination
v-show=
"total>0"
:total=
"total"
:page
.
sync=
"queryParams.page"
:limit
.
sync=
"queryParams.rows"
@
pagination=
"getList"
/>
<!-- 添加或修改banner管理配置对话框 -->
<el-dialog
:title=
"title"
:visible
.
sync=
"open"
width=
"500px"
append-to-body
>
<el-form
ref=
"form"
:model=
"form"
:rules=
"rules"
size=
"small"
label-width=
"90px"
>
<el-form-item
label=
"分类"
prop=
"type"
>
<!-- <el-input v-model.trim="form.type" show-word-limit :maxlength="32" placeholder="请输入类型" />-->
<el-select
v-model
.
trim=
"form.type"
show-word-limit
placeholder=
"请输入类型"
style=
"width: 70%"
>
<el-option
label=
"课程资源"
value=
"0"
/>
<el-option
label=
"其他资源"
value=
"1"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"名称"
prop=
"bannerName"
>
<el-input
v-model
.
trim=
"form.bannerName"
show-word-limit
:maxlength=
"500"
placeholder=
"请输入banner名字"
/>
</el-form-item>
<el-form-item
label=
"图片"
prop=
"bannerPicture"
>
<el-upload
:show-file-list=
"false"
list-type=
"picture-card"
action=
"#"
:http-request=
"handleUpload"
:on-success=
"handleAvatarSuccess"
:before-upload=
"beforeAvatarUpload"
:on-remove=
"handleRemove"
>
<img
v-if=
"form.url"
:src=
"form.url"
style=
"height: 150px;width: 150px"
>
<i
v-else
class=
"el-icon-plus avatar-uploader-icon"
/>
</el-upload>
</el-form-item>
<el-form-item
label=
"链接地址"
prop=
"linkUrl"
>
<el-input
v-model
.
trim=
"form.linkUrl"
show-word-limit
:maxlength=
"255"
placeholder=
"请输入链接地址"
/>
</el-form-item>
<el-form-item
label=
"排序号"
prop=
"weight"
>
<el-input-number
v-model
.
trim=
"form.weight"
controls-position=
"right"
:min=
"0"
/>
</el-form-item>
<el-form-item
label=
"状态"
>
<el-radio-group
v-model=
"form.flag"
>
<el-radio
label=
"1"
>
启用
</el-radio>
<el-radio
label=
"0"
>
停用
</el-radio>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label="备注" prop="remarks">-->
<!-- <el-input v-model.trim="form.remarks" maxlength="200" show-word-limit type="textarea" placeholder="请输入内容" />-->
<!-- </el-form-item>-->
</el-form>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
class=
"cancelBtn"
@
click=
"cancel"
>
取 消
</el-button>
<el-button
class=
"submitBtn"
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
</div>
</el-dialog>
</div>
</template>
<
script
>
import
commonField
from
'@/utils/commonField'
import
{
addCmsBanner
,
delCmsBanner
,
exportCmsBanner
,
getCmsBanner
,
listCmsBanner
,
updateCmsBanner
}
from
'@/api/contentManagement/cmsBanner'
import
{
uploadPublic
}
from
'@/api/contentManagement/sysContest'
export
default
{
name
:
'CmsBanner'
,
data
()
{
return
{
imageUrl
:
''
,
imagePath
:
'http://49.232.167.247:20020/teaServer/'
,
fileUpload
:
'/dev-api/common/fileUpload?file='
+
this
.
file
+
'&temp='
+
'development'
,
// 遮罩层
loading
:
true
,
// 总条数
total
:
0
,
// banner管理表格数据
cmsBannerList
:
[],
// 弹出层标题
title
:
''
,
// 是否显示弹出层
open
:
false
,
// 状态菜单
statusOptions
:
[
{
dictLabel
:
'启用'
,
dictValue
:
'1'
},
{
dictLabel
:
'停用'
,
dictValue
:
'0'
}
],
// 查询参数
queryParams
:
{
page
:
1
,
rows
:
10
,
bannerPicture
:
undefined
,
bannerName
:
undefined
,
type
:
undefined
,
weight
:
undefined
,
linkUrl
:
undefined
,
flag
:
''
},
imagUrl
:
''
,
// 表单参数
form
:
{},
// 表单校验
rules
:
{
bannerName
:
[
{
required
:
true
,
message
:
'请输入名称'
,
trigger
:
'blur'
}
],
type
:
[
{
required
:
true
,
message
:
'请输入类型'
,
trigger
:
'blur'
}
],
weight
:
[
{
required
:
true
,
message
:
'请输入权重'
,
trigger
:
'blur'
}
],
bannerPicture
:
[
{
required
:
true
,
message
:
'请上传图片'
,
trigger
:
'blur'
}
]
}
}
},
computed
:
{
commonField
()
{
return
commonField
}
},
created
()
{
this
.
getList
()
// 列表查询
},
methods
:
{
// 封面图片预览
justEnter
(
event
)
{},
justOut
(
event
)
{},
/**
* @description: 点击蒙版关闭预览图片
* @author: gaoyu
* @param: imageId
* @return:
**/
handleClickStop
(
imageId
)
{
this
.
$nextTick
(()
=>
{
var
domImageView
=
document
.
querySelector
(
`#
${
this
.
step
(
imageId
)}
.el-image-viewer__mask`
)
if
(
!
domImageView
)
{
return
}
var
closeButton
=
document
.
querySelector
(
`#
${
this
.
step
(
imageId
)}
.el-image-viewer__close`
)
domImageView
.
addEventListener
(
'click'
,
()
=>
{
closeButton
.
click
()
})
})
},
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload
(
file
)
{
const
formData
=
new
FormData
()
formData
.
append
(
'file'
,
file
.
file
)
formData
.
append
(
'temp'
,
'CmsBanner'
)
uploadPublic
(
formData
).
then
(
res
=>
{
this
.
form
.
bannerPicture
=
res
.
data
.
businessId
this
.
form
.
url
=
res
.
data
.
url
})
},
handleAvatarSuccess
(
res
,
file
)
{
console
.
log
(
'res'
,
res
)
this
.
imageUrl
=
URL
.
createObjectURL
(
file
.
raw
)
this
.
form
.
bannerPicture
=
res
.
data
.
businessId
this
.
form
.
url
=
res
.
data
.
url
},
beforeAvatarUpload
(
file
)
{
this
.
file
=
file
},
step
(
index
)
{
return
'step'
+
index
},
handleRemove
(
file
,
fileList
)
{
console
.
log
(
file
,
fileList
)
},
/** 查询banner管理列表 */
getList
()
{
this
.
loading
=
true
listCmsBanner
(
this
.
queryParams
).
then
(
response
=>
{
this
.
cmsBannerList
=
response
.
rows
this
.
total
=
response
.
total
this
.
loading
=
false
}
)
},
// 取消按钮
cancel
()
{
this
.
open
=
false
this
.
reset
()
},
// 表单重置
reset
()
{
this
.
form
=
{
businessId
:
undefined
,
bannerPicture
:
undefined
,
bannerName
:
undefined
,
type
:
undefined
,
weight
:
undefined
,
remarks
:
undefined
,
linkUrl
:
undefined
,
flag
:
'1'
}
this
.
resetForm
(
'form'
)
},
/** 查询按钮操作 */
handleQuery
()
{
this
.
queryParams
.
page
=
1
this
.
getList
()
},
/** 重置按钮操作 */
resetQuery
()
{
this
.
queryParams
=
{
page
:
1
,
rows
:
10
,
bannerPicture
:
undefined
,
bannerName
:
undefined
,
type
:
undefined
,
weight
:
undefined
,
linkUrl
:
undefined
,
flag
:
''
}
this
.
handleQuery
()
},
/** 新增按钮操作 */
handleAdd
()
{
this
.
reset
()
this
.
open
=
true
this
.
title
=
'添加banner'
},
/** 修改按钮操作 */
handleUpdate
(
row
)
{
this
.
reset
()
const
id
=
row
.
businessId
getCmsBanner
(
id
).
then
(
response
=>
{
this
.
form
=
response
.
data
this
.
form
.
url
=
this
.
imagePath
+
response
.
data
.
url
this
.
open
=
true
this
.
title
=
'修改banner'
})
},
// 改变状态
handleStatusChange
(
row
)
{
const
text
=
row
.
flag
===
'1'
?
'启用'
:
'停用'
this
.
$confirm
(
'确认操作?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(
function
()
{
return
updateCmsBanner
(
row
)
}).
then
(()
=>
{
this
.
$message
({
message
:
text
+
'成功'
,
type
:
'success'
})
}).
catch
(
function
()
{
row
.
flag
=
row
.
flag
===
'0'
?
'1'
:
'0'
})
},
/** 提交按钮 */
submitForm
:
function
()
{
this
.
$refs
[
'form'
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
this
.
form
.
businessId
!==
undefined
)
{
updateCmsBanner
(
this
.
form
).
then
(
response
=>
{
this
.
msgSuccess
(
'修改成功'
)
this
.
open
=
false
this
.
getList
()
})
}
else
{
addCmsBanner
(
this
.
form
).
then
(
response
=>
{
this
.
msgSuccess
(
'新增成功'
)
this
.
open
=
false
this
.
getList
()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete
(
row
)
{
const
id
=
row
.
businessId
this
.
$confirm
(
'是否确认操作?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(
function
()
{
return
delCmsBanner
(
id
)
}).
then
(()
=>
{
this
.
getList
()
this
.
$message
({
message
:
'删除成功'
,
type
:
'success'
})
}).
catch
(
function
()
{
})
},
/** 导出按钮操作 */
handleExport
()
{
const
queryParams
=
this
.
queryParams
this
.
$confirm
(
'是否确认操作?'
,
'警告'
,
{
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(
function
()
{
return
exportCmsBanner
(
queryParams
).
then
(
response
=>
{
const
blob
=
new
Blob
([
response
])
const
downloadElement
=
document
.
createElement
(
'a'
)
const
href
=
window
.
URL
.
createObjectURL
(
blob
)
// 创建下载的链接
downloadElement
.
href
=
href
downloadElement
.
download
=
'banner管理信息'
+
'.xls'
// 下载后文件名
document
.
body
.
appendChild
(
downloadElement
)
downloadElement
.
click
()
// 点击下载
document
.
body
.
removeChild
(
downloadElement
)
// 下载完成移除元素
window
.
URL
.
revokeObjectURL
(
href
)
// 释放掉blob对象
})
})
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.app-container
{
font-size
:
18px
;
padding
:
0
;
::v-deep
.el-table
td
:nth-child
(
3
)
.cell
{
margin
:
10px
;
text-align
:
center
!
important
;
}
font-size
:
18px
;
padding
:
0
;
.placeholder
{
height
:
1
.3vh
;
background-color
:
#F4F4F4
;
margin-bottom
:
10px
}
.placeholder
{
height
:
1
.3vh
;
background-color
:
#F4F4F4
;
margin-bottom
:
10px
}
}
</
style
>
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