html片段
<style scoped>
.box {
padding: 20px 20px 10px 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
border-radius: 0 0 6px 6px;
box-sizing: border-box;
}
.header {
display: flex;
margin: 20px 0;
}
.header .center {
display: flex;
align-items: center;
margin-right: 15px;
}
.main {
margin: 10px 0;
}
.inputWidth {
width: 215px;
}
::v-deep .el-input-number .el-input__inner {
text-align: left;
}
::v-deep .fillet-radio img {
width: 40px;
height: 40px;
object-fit: contain;
}
</style>
<template>
<div class="box">
<el-breadcrumb separator="-">
<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>基础配置</el-breadcrumb-item>
<el-breadcrumb-item>推广渠道管理</el-breadcrumb-item>
</el-breadcrumb>
<br />
<el-form ref="query" :inline="true" :model="query" label-width="100px">
<el-form-item label="渠道编号">
<el-input
v-model="query.types"
placeholder="请输入渠道编号"
@keyup.enter.native="getquery"
></el-input>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="query.types" placeholder="请选择">
<el-option label="全部" value=""></el-option>
<el-option label="自定义" value="2"></el-option>
<el-option label="官方定义" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="reset" v-hasPermi="['/web/admin/room/topic/list']"
>重置</el-button
>
<el-button
type="primary"
@click="getquery"
v-hasPermi="['/web/admin/room/topic/list']"
>查询</el-button
>
</el-form-item>
</el-form>
<div style="font-size: 14px">
<el-button
type="primary"
@click="open('add')"
v-hasPermi="['/web/admin/room/topic/add']"
>添加</el-button
>
</div>
<div class="main">
<el-table
v-loading="loading"
:border="true"
stripe
:data="list"
style="width: 100%"
>
<el-table-column prop="Title" label="话题内容"> </el-table-column>
<el-table-column prop="StanceA" label="立场1"> </el-table-column>
<el-table-column prop="StanceB" label="立场2"> </el-table-column>
<el-table-column prop="Types" label="类型">
<template slot-scope="scope">
{{ scope.row.Types == 1 ? "官方定义" : "自定义" }}
</template>
</el-table-column>
<el-table-column prop="StaffName" label="操作人"> </el-table-column>
<el-table-column prop="UpdateTime" label="操作时间"> </el-table-column>
<el-table-column fixed="right" label="操作" width="150px">
<template slot-scope="scope">
<el-button
type="text"
style="color: #409eff"
v-hasPermi="['/web/admin/room/topic/edit']"
@click="open('edit', scope.row)"
>编辑</el-button
>
</template>
</el-table-column>
</el-table>
<br />
<div>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="query.page"
:hide-on-single-page="true"
:background="true"
:page-sizes="[10, 20, 50, 100]"
:page-size="query.size"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
>
</el-pagination>
</div>
</div>
<el-dialog
:title="`${getTitle}话题`"
:visible.sync="modal.dialog"
@close="closeType"
>
<el-form
:model="modal.form"
:rules="rules"
ref="ruleForm"
label-width="100px"
class="demo-ruleForm"
>
<el-form-item label="直播话题" prop="Title">
<languageSelect
v-if="modal.dialog"
:TextId="modal.form.Title"
searchName="直播话题"
sceneType="11"
@handleSuccess="
(res) => {
modal.form.Title = res.TextId;
}
"
></languageSelect>
</el-form-item>
<el-form-item label="立场1" prop="StanceA">
<languageSelect
v-if="modal.dialog"
:TextId="modal.form.StanceA"
searchName="立场1"
sceneType="11"
@handleSuccess="
(res) => {
modal.form.StanceA = res.TextId;
}
"
></languageSelect>
</el-form-item>
<el-form-item label="立场2" prop="StanceB">
<languageSelect
v-if="modal.dialog"
:TextId="modal.form.StanceB"
searchName="立场2"
sceneType="11"
@handleSuccess="
(res) => {
modal.form.StanceB = res.TextId;
}
"
></languageSelect>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="modal.dialog = false">取 消</el-button>
<el-button
type="primary"
@click="handleConfirm"
:loading="buttonLoading"
>确 定</el-button
>
</span>
</el-dialog>
</div>
</template>
<script>
import languageSelect from "@/components/languageSelect/index.vue";
export default {
components: {
languageSelect,
},
data() {
return {
loading: false,
buttonLoading: false,
times: [],
query: {
page: 1,
size: 10,
types: "",
},
radio: 1,
total: 0,
getTitle: "添加",
isType: "add",
modal: {
dialog: false,
form: {
Id: "",
Title: "", // 题目
StanceA: "", // 立场1
StanceB: "", // 立场2
},
},
list: [],
rules: {
Title: [
{ required: true, message: "请选择直播话题", trigger: "change" },
],
StanceA: [
{ required: true, message: "请选择立场1", trigger: "change" },
],
StanceB: [
{ required: true, message: "请选择立场2", trigger: "change" },
],
},
options: [],
todayCount: 0,
totalCount: 0,
};
},
created() {
this.getPage();
},
methods: {
getPage() {
this.loading = true;
this.axios
.get(`/room/topic/list`, {
params: {
page: this.query.page - 1,
size: this.query.size,
types: this.query.types,
},
})
.then((res) => {
console.log(res);
if (res.data.Code === "6000") {
this.list = res.data.Result.list ? res.data.Result.list : [];
this.total = res.data.Result.count ? res.data.Result.count : 0;
}
})
.finally(() => {
this.loading = false;
});
},
reset() {
this.query = {
page: 1,
size: 10,
types: "",
};
this.getquery();
},
handleConfirm() {
this.$refs["ruleForm"].validate((valid) => {
if (!valid) {
return false;
}
let item = this.modal.form;
let paramsAdd = {
Title: item.Title,
StanceA: item.StanceA,
StanceB: item.StanceB,
};
let paramsEdit = {
Id: item.Id,
Title: item.Title,
StanceA: item.StanceA,
StanceB: item.StanceB,
};
this.buttonLoading = true;
if (this.isType === "add") {
this.axios
.post("/room/topic/add", paramsAdd)
.then((res) => {
if (res.data.Code === "6000") {
this.$message.success("操作成功");
this.modal.dialog = false;
this.getPage();
} else {
this.$message.error(res.data.Msg);
}
})
.finally(() => {
this.buttonLoading = false;
});
} else if (this.isType === "edit") {
this.axios
.post("/room/topic/edit", paramsEdit)
.then((res) => {
if (res.data.Code === "6000") {
this.$message.success("操作成功");
this.modal.dialog = false;
this.getPage();
} else {
this.$message.error(res.data.Msg);
}
})
.finally(() => {
this.buttonLoading = false;
});
}
});
},
closeType() {
this.modal.form = {
Id: "",
Title: "", // 题目
StanceA: "", // 立场1
StanceB: "", // 立场2
};
},
open(type, data) {
this.isType = type;
let item = JSON.parse(JSON.stringify(data || ""));
console.log(item);
if (type === "add") {
this.getTitle = "添加";
} else if (type === "edit") {
this.getTitle = "编辑";
this.modal.form = {
Id: item.Id,
Title: item.TitleTextId, // 题目
StanceA: item.StanceATextId, // 立场1
StanceB: item.StanceBTextId, // 立场2
};
}
if (this.$refs.ruleForm) {
this.$refs.ruleForm.clearValidate();
}
this.modal.dialog = true;
},
//分页-查询
getquery() {
this.query.page = 1;
this.getPage();
},
handleSizeChange(val) {
this.query.size = val;
this.getPage();
},
handleCurrentChange(val) {
this.query.page = val;
this.getPage();
},
},
};
</script>