championSay.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <section class="content">
  3. <h4>文章数据</h4>
  4. <el-divider></el-divider>
  5. <el-form label-width="80px" class="filter-form">
  6. <el-row>
  7. <el-col :span="4">
  8. <el-form-item label="标题">
  9. <el-input
  10. @clear="getData()"
  11. clearable
  12. v-model="queryParams.name"
  13. placeholder="请输入标题"
  14. size="mini"
  15. ></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="4">
  19. <el-form-item label="标题">
  20. <el-select v-model="queryParams.category" placeholder="" size="mini" clearable @clear="getData" @change="getData">
  21. <el-option
  22. v-for="item in categoryList"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="5">
  31. <el-form-item label="是否置顶">
  32. <el-select
  33. v-model="queryParams.isbanner"
  34. placeholder="请选择是否置顶"
  35. @change="getData()"
  36. size="mini"
  37. clearable
  38. >
  39. <el-option
  40. v-for="item in bannerList"
  41. :key="item.value"
  42. :label="item.label"
  43. :value="item.value"
  44. >
  45. </el-option>
  46. </el-select>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="4">
  50. <el-form-item label-width="10" style="margin-left: 10px">
  51. <el-button type="primary" @click="getData" size="mini"
  52. >筛选</el-button
  53. >
  54. <el-button
  55. type="primary"
  56. plain
  57. icon="el-icon-plus"
  58. size="mini"
  59. @click="handleAdd"
  60. >新增冠军心得</el-button
  61. >
  62. </el-form-item>
  63. </el-col>
  64. </el-row>
  65. </el-form>
  66. <el-table
  67. v-loading="loading"
  68. :data="list"
  69. style="width: 100%; margin-top: 10px"
  70. height="50vh"
  71. >
  72. <el-table-column align="center" prop="name" label="标题" />
  73. <el-table-column align="center" prop="name" label="标题">
  74. <template slot-scope="scope">
  75. <img :src="scope.row.img" width="180" height="80" alt="">
  76. </template>
  77. </el-table-column>
  78. <el-table-column align="center" prop="isbanner" label="置顶">
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.isbanner == 0">未置顶</span>
  81. <span v-if="scope.row.isbanner == 1">已置顶</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column align="center" prop="date" label="状态">
  85. <template slot-scope="scope">
  86. <span v-if="scope.row.status == 1">编辑中</span>
  87. <span v-if="scope.row.status == 2">上线</span>
  88. <span v-if="scope.row.status == -1">下线</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column align="center" prop="category" label="创建时间" />
  92. <el-table-column align="center" prop="ctime" label="创建时间" />
  93. <el-table-column align="center" prop="date" label="操作">
  94. <template slot-scope="scope">
  95. <el-button @click="pushArticle(scope.row)" size="mini" type="primary"
  96. >推送</el-button
  97. >
  98. <el-button @click="handleEdit(scope.row)" size="mini" type="warning"
  99. >编辑</el-button
  100. >
  101. <el-button @click="del(scope.row.id)" size="mini" type="danger"
  102. >删除</el-button
  103. >
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <Page
  108. ref="pageButton"
  109. :current="form.page"
  110. :page_size="form.page_size"
  111. :total="total"
  112. @pageChange="gopage"
  113. />
  114. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  115. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  116. <el-form-item label="比赛名称" prop="name">
  117. <el-input
  118. clearable
  119. v-model="form.name"
  120. placeholder="请输入比赛名称"
  121. ></el-input>
  122. </el-form-item>
  123. <el-form-item label="开始时间" prop="start_time">
  124. <el-date-picker
  125. v-model="form.start_time"
  126. type="date"
  127. placeholder="选择日期"
  128. format="yyyy-MM-dd"
  129. value-format="yyyy-MM-dd"
  130. size="mini"
  131. >
  132. </el-date-picker>
  133. </el-form-item>
  134. <el-form-item label="结束时间" prop="end_time">
  135. <el-date-picker
  136. v-model="form.end_time"
  137. type="date"
  138. placeholder="选择日期"
  139. format="yyyy-MM-dd"
  140. value-format="yyyy-MM-dd"
  141. size="mini"
  142. >
  143. </el-date-picker>
  144. </el-form-item>
  145. </el-form>
  146. <div slot="footer" class="dialog-footer">
  147. <el-button type="primary" @click="submitForm">确 定</el-button>
  148. <el-button @click="open = false">取 消</el-button>
  149. </div>
  150. </el-dialog>
  151. </section>
  152. </template>
  153. <script>
  154. import Page from "../../components/Page";
  155. export default {
  156. components: {
  157. Page,
  158. },
  159. data() {
  160. return {
  161. loading: false,
  162. queryParams: {
  163. page: 1,
  164. },
  165. form: {},
  166. list: [{}, {}],
  167. total: 0,
  168. title: "新增赛事",
  169. open: false,
  170. rules: {
  171. name: [{ required: true, message: "请输入比赛名称", trigger: "blur" }],
  172. start_time: [
  173. { required: true, message: "请输入开始时间", trigger: "blur" },
  174. ],
  175. end_time: [
  176. { required: true, message: "请输入结束时间", trigger: "blur" },
  177. ],
  178. },
  179. matchList: [],
  180. groupList: [],
  181. userList: [],
  182. categoryList:[
  183. {label:"游资专场",value:"游资专场"},
  184. {label:"冠军交割",value:"冠军交割"},
  185. {label:"牛人专场",value:"牛人专场"},
  186. {label:"妖股列传",value:"妖股列传"}
  187. ],
  188. bannerList: [
  189. { label: "未置顶", value: 0 },
  190. { label: "已置顶", value: 1 },
  191. ],
  192. };
  193. },
  194. methods: {
  195. del(id) {
  196. this.$confirm("确定删除吗?", "提示", {
  197. type: "warning",
  198. }).then(() => {
  199. this.$api.delArticle({ id: id }).then((res) => {
  200. this.$message({
  201. message: "删除成功",
  202. type: "success",
  203. });
  204. this.getData();
  205. });
  206. });
  207. },
  208. gopage(size) {
  209. if (size) {
  210. this.queryParams.page_size = size;
  211. }
  212. this.queryParams.page = this.$refs.pageButton.page;
  213. this.getData();
  214. },
  215. getData() {
  216. this.loading = true;
  217. //
  218. this.queryParams.type = "champion";
  219. this.$api.getArticleList(this.queryParams).then((res) => {
  220. this.list = res.data.data.list;
  221. this.total = res.data.data.total;
  222. this.loading = false;
  223. });
  224. },
  225. handleAdd() {
  226. this.open = true;
  227. this.title = "新增赛事";
  228. this.form = {};
  229. this.$router.push({ path: "/addChampionSay" });
  230. },
  231. handleEdit(row) {
  232. this.open = true;
  233. this.title = "新增赛事";
  234. // this.form={}
  235. this.$router.push({ path: "/addChampionSay", query: { id: row.id } });
  236. },
  237. /** 提交按钮 */
  238. submitForm() {
  239. this.$refs["form"].validate((valid) => {
  240. if (valid) {
  241. if (this.form.id != null) {
  242. this.$api.updateMatch(this.form).then((response) => {
  243. this.msgSuccess("修改成功");
  244. this.open = false;
  245. this.getData();
  246. });
  247. } else {
  248. this.$api.addMatch(this.form).then((response) => {
  249. this.msgSuccess("新增成功");
  250. this.open = false;
  251. this.getData();
  252. });
  253. }
  254. }
  255. });
  256. },
  257. pushArticle(row){
  258. this.$confirm("确认推送该文章给所有用户?", "提示", {
  259. type: "warning",
  260. }).then(() => {
  261. this.$api.pushArticle({ id: row.id }).then((res) => {
  262. this.$message({
  263. message: "推送成功",
  264. type: "success",
  265. });
  266. this.getData();
  267. });
  268. });
  269. }
  270. },
  271. created() {
  272. this.getData();
  273. },
  274. };
  275. </script>