|
|
|
@ -1,52 +1,66 @@ |
|
|
|
|
<template> |
|
|
|
|
<!-- 营销推广管理 --> |
|
|
|
|
<div style="padding-top: 24px"> |
|
|
|
|
<div style="margin-bottom: 10px;text-align: right;"> |
|
|
|
|
<el-button v-auth="'平台自建:新增'" type="primary" round @click="add">新增</el-button> |
|
|
|
|
</div> |
|
|
|
|
<el-table :data="list" class="table" ref="table" stripe header-align="center" row-key="id"> |
|
|
|
|
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="courseName" label="图片" min-width="150" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-upload |
|
|
|
|
class="avatar-uploader" |
|
|
|
|
accept=".jpg,.png,.jpeg" |
|
|
|
|
:on-success="res => uploadSuccess(res, scope.row)" |
|
|
|
|
:limit="1" |
|
|
|
|
:action="api.fileupload" |
|
|
|
|
:headers="headers" |
|
|
|
|
:show-file-list="false" |
|
|
|
|
name="file" |
|
|
|
|
> |
|
|
|
|
<img v-if="scope.row.pic" :src="scope.row.pic" class="avatar"> |
|
|
|
|
<div class="uploader-default" v-else> |
|
|
|
|
<i class="el-icon-plus"></i> |
|
|
|
|
<p>上传图片</p> |
|
|
|
|
</div> |
|
|
|
|
</el-upload> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="courseName" label="标题" min-width="150" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input v-model="scope.row.title" placeholder="请输入标题" maxlength="100"></el-input> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="courseName" label="链接" min-width="150" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-input v-model="scope.row.title" placeholder="请输入链接" maxlength="100"></el-input> |
|
|
|
|
<img width="100" :src="scope.row.banner" alt=""> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column prop="title" label="标题" min-width="150" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="url" label="链接" min-width="150" align="center"></el-table-column> |
|
|
|
|
<el-table-column label="操作" align="center" width="250"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-switch |
|
|
|
|
v-model="scope.row.isShelves" |
|
|
|
|
:active-value="1" |
|
|
|
|
:inactive-value="0" |
|
|
|
|
v-model="scope.row.isOpen" |
|
|
|
|
:active-value="0" |
|
|
|
|
:inactive-value="1" |
|
|
|
|
@change="switchOff($event, scope.row)" |
|
|
|
|
v-auth="'/curriculum:上下架'"> |
|
|
|
|
</el-switch> |
|
|
|
|
<el-button class="m-l-10" v-auth="'平台自建:编辑信息'" type="text" @click="editCourse(scope.row)">编辑</el-button> |
|
|
|
|
<el-button style="margin-left: 10px;" v-auth="'平台自建:删除'" type="text" @click="edit(scope.row)">编辑</el-button> |
|
|
|
|
<el-button v-auth="'平台自建:删除'" type="text" @click="handleDelete(scope.row)">删除</el-button> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</el-table> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-dialog :title="(form.id ? '编辑' : '新增') + 'banner'" :visible.sync="bannerVisible" width="500px" class="dialog" :close-on-click-modal="false"> |
|
|
|
|
<el-form ref="form" label-width="60px"> |
|
|
|
|
<el-form-item label="图片"> |
|
|
|
|
<el-upload |
|
|
|
|
class="avatar-uploader" |
|
|
|
|
accept=".jpg,.png,.jpeg" |
|
|
|
|
:on-success="uploadSuccess" |
|
|
|
|
:limit="1" |
|
|
|
|
:action="api.fileupload" |
|
|
|
|
:headers="headers" |
|
|
|
|
:show-file-list="false" |
|
|
|
|
name="file" |
|
|
|
|
> |
|
|
|
|
<img v-if="form.banner" :src="form.banner" class="avatar"> |
|
|
|
|
<div class="uploader-default" v-else> |
|
|
|
|
<i class="el-icon-plus"></i> |
|
|
|
|
<p>上传图片</p> |
|
|
|
|
</div> |
|
|
|
|
</el-upload> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="标题"> |
|
|
|
|
<el-input v-model="form.title" placeholder="请输入标题" maxlength="100"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="链接"> |
|
|
|
|
<el-input v-model="form.url" placeholder="请输入链接" maxlength="100"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button @click="bannerVisible = false">取消</el-button> |
|
|
|
|
<el-button type="primary" @click="submitBanner">确定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
@ -59,36 +73,35 @@ export default { |
|
|
|
|
headers: { |
|
|
|
|
token: sessionStorage.getItem("token") |
|
|
|
|
}, |
|
|
|
|
list: [{}], |
|
|
|
|
list: [], |
|
|
|
|
bannerVisible: false, |
|
|
|
|
form: { |
|
|
|
|
id: '', |
|
|
|
|
banner: '', |
|
|
|
|
title: '', |
|
|
|
|
url: '', |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
|
|
|
|
|
this.getList() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
getList() { |
|
|
|
|
this.$post(this.api.listTheoreticalCourse, { |
|
|
|
|
pageNum: this.page, |
|
|
|
|
pageSize: this.pageSize, |
|
|
|
|
keyWord: this.keyword, |
|
|
|
|
createPlatform: 0, |
|
|
|
|
platformSource: Setting.platformSource, |
|
|
|
|
...this.form |
|
|
|
|
this.$post(this.api.listMarketing, { |
|
|
|
|
pageNum: 1, |
|
|
|
|
pageSize: 1000 |
|
|
|
|
}).then(({ page }) => { |
|
|
|
|
this.list = page.records; |
|
|
|
|
this.total = page.total; |
|
|
|
|
if (!this.list.length && this.total) { |
|
|
|
|
this.page--; |
|
|
|
|
this.getData(); |
|
|
|
|
} |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
handleExceed() { // 文件超出个数限制时的钩子 |
|
|
|
|
this.$message.warning("当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!"); |
|
|
|
|
}, |
|
|
|
|
uploadSuccess(res, row) { // 文件上传成功时的钩子 |
|
|
|
|
row.pic = res.data.filesResult.fileUrl; |
|
|
|
|
uploadSuccess(res) { // 文件上传成功时的钩子 |
|
|
|
|
this.form.banner = res.data.filesResult.fileUrl; |
|
|
|
|
}, |
|
|
|
|
uploadError(err, file, fileList) { // 文件上传失败时的钩子 |
|
|
|
|
this.$message({ |
|
|
|
@ -103,20 +116,37 @@ export default { |
|
|
|
|
handleRemove(file, fileList) { // 文件列表移除文件时的钩子 |
|
|
|
|
// this.form.coverUrl = '' |
|
|
|
|
}, |
|
|
|
|
addCourse() { |
|
|
|
|
this.$router.push("/addTheoreticalCourse"); |
|
|
|
|
add() { |
|
|
|
|
this.form = { |
|
|
|
|
id: '', |
|
|
|
|
banner: '', |
|
|
|
|
title: '', |
|
|
|
|
url: '', |
|
|
|
|
} |
|
|
|
|
this.bannerVisible = true |
|
|
|
|
}, |
|
|
|
|
edit(row) { |
|
|
|
|
this.form = JSON.parse(JSON.stringify(row)) |
|
|
|
|
this.bannerVisible = true |
|
|
|
|
}, |
|
|
|
|
editCourse(row) { |
|
|
|
|
this.$router.push(`/addTheoreticalCourse?id=${row.id}`); |
|
|
|
|
// banner弹框提交 |
|
|
|
|
submitBanner() { |
|
|
|
|
const { form } = this |
|
|
|
|
if (!form.banner) return util.errorMsg('请上传图片') |
|
|
|
|
if (!form.title) return util.errorMsg('请输入标题') |
|
|
|
|
this.$post(this.api[form.id ? 'updateMarketing' : 'saveMarketing'], form).then(res => { |
|
|
|
|
this.getList() |
|
|
|
|
this.bannerVisible = false |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
|
handleDelete(row) { |
|
|
|
|
this.$confirm("此删除操作不可逆,是否确认删除选中项?", "提示", { |
|
|
|
|
type: "warning" |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
this.$post(`${this.api.delTheoreticalCourse}?ids=${row.id}`).then(res => { |
|
|
|
|
this.$post(`${this.api.delMarketing}?ids=${row.id}`).then(res => { |
|
|
|
|
util.successMsg("删除成功"); |
|
|
|
|
this.initData(); |
|
|
|
|
this.getList(); |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|