Article.vue 8.4 KB

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