Article.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <style lang="scss">
  2. .preview {
  3. .el-form-item {
  4. margin-bottom: 15px;
  5. }
  6. label,
  7. p {
  8. line-height: 25px !important;
  9. }
  10. }
  11. .el-cascader {
  12. width: 100%;
  13. }
  14. a {
  15. text-decoration: none;
  16. color: #409eff;
  17. cursor: pointer;
  18. }
  19. // 右边
  20. .item-main {
  21. // margin:34px;
  22. // height:600px;
  23. // background: #FFFFFF;
  24. border: 1px solid #dddddd;
  25. box-shadow: 0px 5px 10px 0px rgba(0, 0, 0, 0.13);
  26. border-radius: 20px;
  27. .el-form.over_y {
  28. max-height: calc(100vh - 340px);
  29. }
  30. /deep/.el-form-item__label {
  31. float: none;
  32. }
  33. }
  34. // label样式
  35. .edit_label {
  36. /deep/.el-input__inner {
  37. background: #f5faff;
  38. border: 0px;
  39. padding: 0px;
  40. }
  41. }
  42. /deep/.opicon {
  43. font-weight: bold;
  44. padding: 5px;
  45. color: #3895fe;
  46. }
  47. .tpl_title {
  48. font-size: 18px;
  49. margin: 20px 0;
  50. }
  51. .tpl_form {
  52. margin: 20px;
  53. border: 1px solid #ccc;
  54. border-radius: 20px;
  55. /deep/.el-form-item {
  56. background: none;
  57. }
  58. /deep/.el-form-item__content {
  59. width: 100%;
  60. }
  61. }
  62. .survey_logo {
  63. position: relative;
  64. top: 15px;
  65. left: 20px;
  66. }
  67. .result_dialog .el-dialog{
  68. width: 40%;
  69. margin-top:20vh!important;
  70. }
  71. .result-item{
  72. height: 35px;
  73. .label{
  74. font-weight: 600;
  75. }
  76. }
  77. </style>
  78. <template>
  79. <section>
  80. <p><span>信息管理></span>文章管理</p>
  81. <div class="content">
  82. <div class="filter">
  83. <el-form
  84. size="small"
  85. label-width="70px"
  86. :inline="true"
  87. label-position="left"
  88. >
  89. <el-form-item label="">
  90. <el-input
  91. clearable
  92. placeholder="请输入标题"
  93. v-model="form.name"
  94. ></el-input>
  95. </el-form-item>
  96. <el-form-item>
  97. <el-button type="primary" @click="search">搜索</el-button>
  98. </el-form-item>
  99. <el-form-item style="float: right">
  100. <el-button @click="addArticle" type="primary">发布文章</el-button>
  101. </el-form-item>
  102. </el-form>
  103. </div>
  104. <el-table
  105. class="table"
  106. :data="list"
  107. height="50vh"
  108. border
  109. v-loading="loading"
  110. default-expand-all
  111. row-key="id"
  112. style="width: 100%"
  113. >
  114. <el-table-column prop="name" label="文章名称" width="500px"> </el-table-column>
  115. <el-table-column prop="author" label="作者"></el-table-column>
  116. <el-table-column prop="journal_name" label="来源"></el-table-column>
  117. <el-table-column prop="publish_time" label="出版时间"></el-table-column>
  118. <el-table-column prop="ctime" label="发布时间"></el-table-column>
  119. <el-table-column prop="read_num" label="阅读量"></el-table-column>
  120. <el-table-column prop="zip" width="150" label="操作">
  121. <template slot-scope="scope">
  122. <el-button class="edit" type="text" @click="edit(scope.row)"
  123. >编辑</el-button
  124. >
  125. <el-button class="del" @click="del(scope.row.id)" type="text"
  126. >删除</el-button
  127. >
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <Page
  132. ref="pageButton"
  133. :current="form.page"
  134. :page_size="form.page_size"
  135. :total="total"
  136. @pageChange="gopage"
  137. />
  138. </div>
  139. </section>
  140. </template>
  141. <script>
  142. import Page from "../../components/Page";
  143. import fuEditor from '../../components/fuEditor'
  144. export default {
  145. components: {
  146. Page,
  147. fuEditor
  148. },
  149. data() {
  150. return {
  151. form: { name: "", page: 1, page_size: 20 },
  152. total: 1,
  153. list: [{ name: "2333" }],
  154. loading: false,
  155. rules: {
  156. name: [{ required: true, message: "请输入标题", trigger: "blur" }],
  157. },
  158. };
  159. },
  160. methods: {
  161. search() {
  162. let parm = this.form;
  163. this.getData();
  164. },
  165. openDiag() {
  166. this.form1 = {};
  167. this.dialogVisible = true;
  168. this.dialogTitle = "发送消息";
  169. },
  170. addArticle(){
  171. this.$router.push({path:'/article/article/add'})
  172. },
  173. gopage(size) {
  174. if (size) {
  175. this.form.page_size = size;
  176. }
  177. this.form.page = this.$refs.pageButton.page;
  178. this.getData();
  179. },
  180. getData() {
  181. var parm = this.form;
  182. this.loading = true;
  183. this.$api.getArticleList(parm).then((res) => {
  184. console.log(res)
  185. this.list = res.data.data.list;
  186. this.loading = false;
  187. });
  188. },
  189. del(id) {
  190. this.$confirm("确定删除吗", "提示", {
  191. type: "warning",
  192. }).then(() => {
  193. this.$api.delArticle({ id: id }).then((res) => {
  194. this.$message({
  195. message: "删除成功",
  196. type: "success",
  197. });
  198. this.getData();
  199. });
  200. });
  201. },
  202. edit(row) {
  203. this.$router.push({path:'/article/article/add',query:{id:row.id}})
  204. },
  205. save() {
  206. this.$refs["form1"].validate((valid) => {
  207. if (valid) {
  208. let parm = this.form1;
  209. let id = this.form1.id;
  210. parm.receiver_id = JSON.stringify(parm.receiver_id);
  211. if (id) {
  212. this.$api.editMessage(parm).then((res) => {
  213. if (res.data.code == 0) {
  214. this.$message({
  215. type: "success",
  216. message: "保存成功!",
  217. });
  218. } else {
  219. this.$message.error("保存失败!");
  220. }
  221. this.getData();
  222. this.dialogVisible = false;
  223. });
  224. } else {
  225. this.$api.addMessage(parm).then((res) => {
  226. if (res.data.code == 0) {
  227. this.$message({
  228. type: "success",
  229. message: "保存成功!",
  230. });
  231. } else {
  232. this.$message.error("保存失败!");
  233. }
  234. this.getData();
  235. this.dialogVisible = false;
  236. });
  237. }
  238. }
  239. });
  240. },
  241. },
  242. created() {
  243. this.getData();
  244. },
  245. };
  246. </script>