Article.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. .syncitem{
  78. height:72px;
  79. line-height:72px;
  80. display:flex;
  81. justify-content:space-between;
  82. border-bottom:1px solid #ccc;
  83. }
  84. .syncitem img{
  85. margin:10px;
  86. }
  87. .syncbtn{
  88. margin-top:20px;
  89. text-align: center;
  90. }
  91. </style>
  92. <template>
  93. <section>
  94. <p><span>信息管理></span>文章管理</p>
  95. <div class="content">
  96. <div class="filter">
  97. <el-form
  98. size="small"
  99. label-width="70px"
  100. :inline="true"
  101. label-position="left"
  102. >
  103. <el-form-item label="">
  104. <el-input
  105. clearable
  106. placeholder="请输入标题"
  107. v-model="form.name"
  108. ></el-input>
  109. </el-form-item>
  110. <el-form-item>
  111. <el-button type="primary" @click="search">搜索</el-button>
  112. </el-form-item>
  113. <el-form-item style="float: right">
  114. <el-button @click="syncToMP" type="primary"
  115. >同步到公众号</el-button
  116. >
  117. <el-button @click="addArticle" type="primary">发布文章</el-button>
  118. </el-form-item>
  119. </el-form>
  120. </div>
  121. <el-table
  122. class="table"
  123. :data="list"
  124. height="50vh"
  125. border
  126. v-loading="loading"
  127. default-expand-all
  128. row-key="id"
  129. style="width: 100%"
  130. @selection-change="handleSelectionChange"
  131. >
  132. <el-table-column type="selection" width="55"> </el-table-column>
  133. <el-table-column prop="name" label="文章名称"> </el-table-column>
  134. <el-table-column prop="img" label="封面图">
  135. <template slot-scope="scope">
  136. <img :src="scope.row.img" alt="" width="120" height="80">
  137. </template>
  138. </el-table-column>
  139. <el-table-column prop="author" label="作者"></el-table-column>
  140. <el-table-column prop="journal_name" label="来源"></el-table-column>
  141. <el-table-column prop="publish_time" label="出版时间"></el-table-column>
  142. <el-table-column prop="ctime" label="发布时间"></el-table-column>
  143. <el-table-column prop="read_num" label="阅读量"></el-table-column>
  144. <el-table-column prop="zip" width="150" label="操作">
  145. <template slot-scope="scope">
  146. <el-button class="edit" type="text" @click="edit(scope.row)"
  147. >编辑</el-button
  148. >
  149. <el-button class="del" @click="del(scope.row.id)" type="text"
  150. >删除</el-button
  151. >
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <Page
  156. ref="pageButton"
  157. :current="form.page"
  158. :page_size="form.page_size"
  159. :total="total"
  160. @pageChange="gopage"
  161. />
  162. <!-- 同步到微信公众号 -->
  163. <el-dialog
  164. class="fu-dialog"
  165. title="同步到微信公众号" width="375px"
  166. :close-on-click-modal="false"
  167. :visible.sync="dialogVisible"
  168. >
  169. <!-- <div>
  170. <img :src="journalLogo" alt="">
  171. </div> -->
  172. <div>
  173. <div v-if="multipleSelection" style="position:relative;">
  174. <img :src="multipleSelection[0].img" alt="" width="310px" height="157px">
  175. <p style="position:absolute;bottom:20px;left:20px;font-weight:bold;color:#ffffff;">{{multipleSelection[0].name}}</p>
  176. </div>
  177. <div v-if="multipleSelection">
  178. <div class="syncitem" v-for="(item,index) in multipleSelection" :key="index">
  179. <p>{{item.name.substring(0,20)}}</p>
  180. <img :src="item.img" alt="" width="48px" height="48px">
  181. </div>
  182. </div>
  183. </div>
  184. <div class="syncbtn">
  185. <el-button type="normal" size="small" @click="dialogVisible=false">取消</el-button>
  186. <el-button type="primary" size="small">确定</el-button>
  187. </div>
  188. </el-dialog>
  189. </div>
  190. </section>
  191. </template>
  192. <script>
  193. import Page from "../../components/Page";
  194. import fuEditor from "../../components/fuEditor";
  195. export default {
  196. components: {
  197. Page,
  198. fuEditor,
  199. },
  200. data() {
  201. return {
  202. form: { name: "", page: 1, page_size: 20 },
  203. total: 1,
  204. list: [{ name: "2333" }],
  205. loading: false,
  206. rules: {
  207. name: [{ required: true, message: "请输入标题", trigger: "blur" }],
  208. },
  209. dialogVisible:false,
  210. journalLogo:"",
  211. multipleSelection:''
  212. };
  213. },
  214. methods: {
  215. syncToMP(){
  216. if(!this.multipleSelection){
  217. this.$message.error("请勾选需要同步到公众号的文章!")
  218. return
  219. }
  220. console.log(this.multipleSelection)
  221. this.dialogVisible = true;
  222. },
  223. handleSelectionChange(val) {
  224. this.multipleSelection = val;
  225. },
  226. search() {
  227. let parm = this.form;
  228. this.getData();
  229. },
  230. openDiag() {
  231. this.form1 = {};
  232. this.dialogVisible = true;
  233. this.dialogTitle = "发送消息";
  234. },
  235. addArticle() {
  236. this.$router.push({ path: "/article/article/add" });
  237. },
  238. gopage(size) {
  239. if (size) {
  240. this.form.page_size = size;
  241. }
  242. this.form.page = this.$refs.pageButton.page;
  243. this.getData();
  244. },
  245. getData() {
  246. var parm = this.form;
  247. this.loading = true;
  248. this.$api.getArticleList(parm).then((res) => {
  249. console.log(res);
  250. this.list = res.data.data.list;
  251. this.total=res.data.data.total
  252. this.loading = false;
  253. });
  254. },
  255. del(id) {
  256. this.$confirm("确定删除吗", "提示", {
  257. type: "warning",
  258. }).then(() => {
  259. this.$api.delArticle({ id: id }).then((res) => {
  260. this.$message({
  261. message: "删除成功",
  262. type: "success",
  263. });
  264. this.getData();
  265. });
  266. });
  267. },
  268. edit(row) {
  269. this.$router.push({
  270. path: "/article/article/add",
  271. query: { id: row.id },
  272. });
  273. },
  274. save() {
  275. this.$refs["form1"].validate((valid) => {
  276. if (valid) {
  277. let parm = this.form1;
  278. let id = this.form1.id;
  279. parm.receiver_id = JSON.stringify(parm.receiver_id);
  280. if (id) {
  281. this.$api.editMessage(parm).then((res) => {
  282. if (res.data.code == 0) {
  283. this.$message({
  284. type: "success",
  285. message: "保存成功!",
  286. });
  287. } else {
  288. this.$message.error("保存失败!");
  289. }
  290. this.getData();
  291. this.dialogVisible = false;
  292. });
  293. } else {
  294. this.$api.addMessage(parm).then((res) => {
  295. if (res.data.code == 0) {
  296. this.$message({
  297. type: "success",
  298. message: "保存成功!",
  299. });
  300. } else {
  301. this.$message.error("保存失败!");
  302. }
  303. this.getData();
  304. this.dialogVisible = false;
  305. });
  306. }
  307. }
  308. });
  309. },
  310. },
  311. created() {
  312. this.getData();
  313. },
  314. };
  315. </script>