123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <section class="content">
- <h4>文章数据</h4>
- <el-divider></el-divider>
- <el-form label-width="80px" class="filter-form">
- <el-row>
- <el-col :span="4">
- <el-form-item label="标题">
- <el-input
- @clear="getData()"
- clearable
- v-model="queryParams.name"
- placeholder="请输入标题"
- size="mini"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="标题">
- <el-select v-model="queryParams.category" placeholder="" size="mini" clearable @clear="getData" @change="getData">
- <el-option
- v-for="item in categoryList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="是否置顶">
- <el-select
- v-model="queryParams.isbanner"
- placeholder="请选择是否置顶"
- @change="getData()"
- size="mini"
- clearable
- >
- <el-option
- v-for="item in bannerList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label-width="10" style="margin-left: 10px">
- <el-button type="primary" @click="getData" size="mini"
- >筛选</el-button
- >
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- >新增冠军心得</el-button
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <el-table
- v-loading="loading"
- :data="list"
- style="width: 100%; margin-top: 10px"
- height="50vh"
- >
- <el-table-column align="center" prop="name" label="标题" />
- <el-table-column align="center" prop="name" label="标题">
- <template slot-scope="scope">
- <img :src="scope.row.img" width="180" height="80" alt="">
- </template>
- </el-table-column>
- <el-table-column align="center" prop="isbanner" label="置顶">
- <template slot-scope="scope">
- <span v-if="scope.row.isbanner == 0">未置顶</span>
- <span v-if="scope.row.isbanner == 1">已置顶</span>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="date" label="状态">
- <template slot-scope="scope">
- <span v-if="scope.row.status == 1">编辑中</span>
- <span v-if="scope.row.status == 2">上线</span>
- <span v-if="scope.row.status == -1">下线</span>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="category" label="创建时间" />
- <el-table-column align="center" prop="ctime" label="创建时间" />
- <el-table-column align="center" prop="date" label="操作">
- <template slot-scope="scope">
- <el-button @click="pushArticle(scope.row)" size="mini" type="primary"
- >推送</el-button
- >
- <el-button @click="handleEdit(scope.row)" size="mini" type="warning"
- >编辑</el-button
- >
- <el-button @click="del(scope.row.id)" size="mini" type="danger"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <Page
- ref="pageButton"
- :current="form.page"
- :page_size="form.page_size"
- :total="total"
- @pageChange="gopage"
- />
- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="比赛名称" prop="name">
- <el-input
- clearable
- v-model="form.name"
- placeholder="请输入比赛名称"
- ></el-input>
- </el-form-item>
- <el-form-item label="开始时间" prop="start_time">
- <el-date-picker
- v-model="form.start_time"
- type="date"
- placeholder="选择日期"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"
- size="mini"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item label="结束时间" prop="end_time">
- <el-date-picker
- v-model="form.end_time"
- type="date"
- placeholder="选择日期"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"
- size="mini"
- >
- </el-date-picker>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="open = false">取 消</el-button>
- </div>
- </el-dialog>
- </section>
- </template>
- <script>
- import Page from "../../components/Page";
- export default {
- components: {
- Page,
- },
- data() {
- return {
- loading: false,
- queryParams: {
- page: 1,
- },
- form: {},
- list: [{}, {}],
- total: 0,
- title: "新增赛事",
- open: false,
- rules: {
- name: [{ required: true, message: "请输入比赛名称", trigger: "blur" }],
- start_time: [
- { required: true, message: "请输入开始时间", trigger: "blur" },
- ],
- end_time: [
- { required: true, message: "请输入结束时间", trigger: "blur" },
- ],
- },
- matchList: [],
- groupList: [],
- userList: [],
- categoryList:[
- {label:"游资专场",value:"游资专场"},
- {label:"冠军交割",value:"冠军交割"},
- {label:"牛人专场",value:"牛人专场"},
- {label:"妖股列传",value:"妖股列传"}
- ],
- bannerList: [
- { label: "未置顶", value: 0 },
- { label: "已置顶", value: 1 },
- ],
- };
- },
- methods: {
- del(id) {
- this.$confirm("确定删除吗?", "提示", {
- type: "warning",
- }).then(() => {
- this.$api.delArticle({ id: id }).then((res) => {
- this.$message({
- message: "删除成功",
- type: "success",
- });
- this.getData();
- });
- });
- },
- gopage(size) {
- if (size) {
- this.queryParams.page_size = size;
- }
- this.queryParams.page = this.$refs.pageButton.page;
- this.getData();
- },
- getData() {
- this.loading = true;
- //
- this.queryParams.type = "champion";
- this.$api.getArticleList(this.queryParams).then((res) => {
- this.list = res.data.data.list;
- this.total = res.data.data.total;
- this.loading = false;
- });
- },
- handleAdd() {
- this.open = true;
- this.title = "新增赛事";
- this.form = {};
- this.$router.push({ path: "/addChampionSay" });
- },
- handleEdit(row) {
- this.open = true;
- this.title = "新增赛事";
- // this.form={}
- this.$router.push({ path: "/addChampionSay", query: { id: row.id } });
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate((valid) => {
- if (valid) {
- if (this.form.id != null) {
- this.$api.updateMatch(this.form).then((response) => {
- this.msgSuccess("修改成功");
- this.open = false;
- this.getData();
- });
- } else {
- this.$api.addMatch(this.form).then((response) => {
- this.msgSuccess("新增成功");
- this.open = false;
- this.getData();
- });
- }
- }
- });
- },
- pushArticle(row){
- this.$confirm("确认推送该文章给所有用户?", "提示", {
- type: "warning",
- }).then(() => {
- this.$api.pushArticle({ id: row.id }).then((res) => {
- this.$message({
- message: "推送成功",
- type: "success",
- });
- this.getData();
- });
- });
- }
- },
- created() {
- this.getData();
- },
- };
- </script>
|