request.js

<template>
<div class="artical-container"><!--卡片--><el-card class="filter-card"><div slot="header" class="clearfix"><!--面包屑导航--><el-breadcrumb separator-class="el-icon-arrow-right"><el-breadcrumb-item :to="{ path: 'home' }">首页</el-breadcrumb-item><el-breadcrumb-item>首页管理</el-breadcrumb-item></el-breadcrumb></div><!--数据--><el-form ref="form" :model="form" label-width="40px" size="mini"><el-form-item label="状态"><el-radio-group v-model="status"><el-radio :label="null">全部</el-radio><el-radio :label="0">草稿</el-radio><el-radio :label="1">待审核</el-radio><el-radio :label="2">审核通过</el-radio><el-radio :label="3">审核失败</el-radio><el-radio :label="4">已删除</el-radio></el-radio-group></el-form-item><el-form-item label="频道"><el-select v-model="channelId" placeholder="请选择频道"><el-option label="全部" :value="null"></el-option><el-option :label="channel.name" :value="channel.id" v-for="(channel,index) in channels" :key="index"></el-option></el-select></el-form-item><el-form-item label="日期"><el-date-pickerv-model="rangeDate"type="datetimerange"placeholder="选择日期时间"align="right"format="yyyy-MM-dd"value-format="yyyy-MM-dd"></el-date-picker></el-form-item><el-form-item><el-button type="primary" :disabled="loading" @click="loadArticals(1)">查询</el-button></el-form-item></el-form></el-card><el-card class="filter-card"><div slot="header" class="clearfix">根据筛选条件有{{totalCount}}条结果</div><!--数据列表--><el-table:data="articals"style="width: 100%" stripe size="mini" ><el-table-columnprop="date"label="封面"v-loading="loading"><template slot-scope="scope"><img v-if="scope.row.cover.images[0]" :src="scope.row.cover.images[0]" class="artical-cover" alt=""><img v-else class="artical-cover" src="./pic_bg.png" alt=""></template></el-table-column><el-table-columnprop="title"label="标题"></el-table-column><el-table-columnprop="status"label="状态"><!--如果需要自定义遍历当前数据--><template slot-scope="scope"><el-tag :type="articalsStatus[scope.row.status].type">{{articalsStatus[scope.row.status].text}}</el-tag><!-- <el-tag v-else-if="scope.row.status===1">待审核</el-tag><el-tag v-else-if="scope.row.status===2" type="success">审核通过</el-tag><el-tag v-else-if="scope.row.status===3" type="danger">审核失败</el-tag><el-tag v-else-if="scope.row.status===4" type="info">已删除</el-tag>--></template></el-table-column><el-table-columnprop="pubdate"label="发布时间"></el-table-column><el-table-columnprop="cover"label="操作"><template slot-scope="scope"><el-button size="mini" icon="el-icon-edit" type="primary" circle></el-button><el-button size="mini" icon="el-icon-delete" type="danger" @click="onDeleteArtical(scope.row.id)" circle></el-button></template></el-table-column></el-table><!--分页--><el-pagination class="list-table"layout="prev, pager, next":total="totalCount" :page-size="pageSize":disabled="loading"@current-change="OnCurrentChange" ></el-pagination></el-card></div>
</template>
<script>
import {getArtical,deleteArtical,getArticalChannels
} from '@/api/artical'export default {name: 'ArticalIndex',created () {this.loadArticals(1)this.loadChannels()},data () {return {loading: true,form: {name: '',region: '',date1: '',date2: '',delivery: false,type: [],resource: '',desc: ''},status: null, // 状态为空 查询文章的状态totalCount: 0, // 初始数据pageSize: 20, // 每页大小articals: [], // 记录文章的数据channels: [],channelId: null, // 文章的频道rangeDate: null, // 日期数据articalsStatus: [{ status: 0, text: '草稿', type: 'info' },{ status: 1, text: '待审核', type: '' },{ status: 2, text: '审核通过', type: 'success' },{ status: 3, text: '审核失败', type: 'warning' },{ status: 4, text: '已删除', type: 'danger' }]}},methods: {// 文章删除onDeleteArtical (articleId) {this.$confirm('确认删除吗', '删除提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {/* 要删除的文章id */deleteArtical(articleId.toString()).then(res => {console.log(res)})}).catch(() => {this.$message({type: 'info',message: '已取消删除'})})},onSubmit () {console.log('submit!')},loadArticals (page = 1) {this.loading = truegetArtical({page,per_page: this.pageSize,status: this.status,channel_id: this.channelId,/**  */begin_pubdate: this.rangeDate ? this.rangeDate[0] : null,end_pubdate: this.rangeDate ? this.rangeDate[1] : null}).then(res => {const { results, total_count: totalCount } = res.data.datathis.totalCount = totalCountthis.articals = results// 关闭加载this.loading = false})},loadChannels () {getArticalChannels().then(res => {console.log(res)this.channels = res.data.data.channels})},OnCurrentChange (page) {this.loadArticals(page)}}
}</script>
<style scope lang="less">
.filter-card{margin-bottom: 30px;
}
.list-table{margin-bottom: 20px;
}
.artical-cover{width: 60px;background-size:cover;
}
</style>

app.vue

<template><div id="app"><router-view/></div>
</template>
<script>
export default {name: 'App'
}
</script>
<style lang="less"></style>

index.vue

<template><div class="login-container"><!--必须用el-form进行包裹--><div class="login-head"></div><!--配置表单验证//必须为表单提供验证对象2添加prop属性3通过el-form组件库里面的rules--><el-form class="login-form" ref="login-form" :model="user" :rules="formRules"><el-form-item prop="mobile"><el-input v-model="user.mobile" placeholder="请输入手机号"></el-input></el-form-item><el-form-item prop="code"><el-input v-model="user.code" placeholder="请输入验证码"></el-input></el-form-item><el-form-item prop="agree"><el-checkbox v-model="checked">我已阅读并同意用户协议和隐私条款</el-checkbox></el-form-item><el-form-item><el-button class="login-btn" type="primary" :loading="loginLoading" @click="onLogin">登录</el-button></el-form-item></el-form></div>
</template><script>import { login } from '@/api/user'
export default {name: 'LoginIndex',components: {},props: {},data () {return {user: {mobile: '', // 手机号code: '', // 验证码agree: false// 是否同意协议},loginLoading: false, // 登录的loding状态/*  checked: false, // 是否同意协议 */formRules: {mobile: [{required: true,message: '手机号不能为空',trigger: 'change'},{ pattern: /^1[3|5|7|9]\d{9}$/, message: '请输入正确的号码格式', trigger: 'change' }],code: [{required: true,message: '验证码不能为空',trigger: 'change'},{ pattern: /^\d{6}$/, message: '请输入正确的验证码格式', trigger: 'change' }],agree: [{// 调用validator: (rule, value, callback) => {if (value) {callback()} else {callback(new Error('请同意用户协议'))}},trigger: 'change'}]}}},methods: {onLogin () {// 获取表单数据// const user = this.user// 触发表单验证 validate是异步this.$refs['login-form'].validate((valid, err) => {console.log(valid)console.log(err)// 如果if (!valid) {return}this.login()})},login () {// 开启loadingthis.loginLoading = true// 验证通过// 请求直接封装login(this.user).then(res => {console.log(res)this.$message({message: '登录成功',type: 'success'})this.loginLoading = false}).catch(err => {console.log('登录失败', err)this.$message.error({message: '手机号或者验证码错误',type: 'warning'})this.loginLoading = false})}}}
</script>
<style scoped lang="less">
.login-container{
position: fixed;left: 0;top: 0;right: 0;bottom: 0;display: flex;justify-content: center;align-items: center;flex-direction: column;background: url("./login_bg.jpg") no-repeat;background-size: cover;.login-head{width: 300px;height: 57px;background:url("./logo_index.png") no-repeat;margin-bottom: 30px;}.login-form{background-color: #fff;padding: 50px;min-width: 300px;.login-btn{width: 100%;}}
}
</style>

main.js

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './styles/index.less'
// 加载组件库
import ElementUI from 'element-ui'
// 加载样式
import 'element-ui/lib/theme-chalk/index.css'
Vue.config.productionTip = false
// 注册组件库
Vue.use(ElementUI)
new Vue({router,render: h => h(App)
}).$mount('#app')

index.js

import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login/index'
Vue.use(VueRouter)// 路由配置表
const routes = [{path: '/login',name: 'login',component: Login
}]
const router = new VueRouter({routes
})export default router

user.js

// 用户登录的请求模块
import request from '@/utils/request'export const login = data => {return request({method: 'POST',url: '/mp/v1_0/authorizations',data})
}// 获取用户信息

index.vue

<template><div class="home-container">首页</div>
</template>
<script>
export default {name: 'HomeIndex',data () {return {}}
}
</script>
<style scoped lang="less"></style>

index.vue

<template><el-container class="layout-container"><el-aside class="aside"><app-aside class="aside-menu"></app-aside></el-aside><el-container><el-header class="header"><div><i class="el-icon-s-fold"></i><span>江苏传智播客科技教育有限公司</span></div><el-dropdown><div class="avatar-wrap"><img class="avatar" src="./avatar.jpg" alt=""><span>歌谣</span><i class="el-icon-arrow-down el-icon--right"></i></div><!--<span>下拉菜单<i class="el-icon-arrow-down el-icon--right"></i></span>--><el-dropdown-menu slot="dropdown"><el-dropdown-item>设置</el-dropdown-item><el-dropdown-item>退出</el-dropdown-item></el-dropdown-menu></el-dropdown></el-header><el-main class="main"><router-view /></el-main></el-container></el-container></template>
<script>
import AppAside from './component/aside'export default {name: 'LayoutIndex',components: { AppAside },component: {AppAside},data () {return {}}
}
</script>
<style scoped lang="less">
.layout-container{position: fixed;left:0;right:0;top:0;bottom: 0;}.aside{width: 100px;background-color: #d3dce6;.aside-menu{height: 100%;}
}
.header{height: 60px;background-color: #b3c0d1;display: flex;justify-content: space-between;align-items: center;border-bottom: 1px solid #ccc;
}
.main{background-color: #e9eef3;
}
.avatar-wrap{display: flex;align-items: center;.avatar{width: 40px;height: 40px;border-radius: 50%;margin-right: 10px;}
}
</style>

aside.vue

<template>
<div class="artical-container"><!--卡片--><el-card class="filter-card"><div slot="header" class="clearfix"><!--面包屑导航--><el-breadcrumb separator-class="el-icon-arrow-right"><el-breadcrumb-item :to="{ path: 'home' }">首页</el-breadcrumb-item><el-breadcrumb-item>首页管理</el-breadcrumb-item></el-breadcrumb></div><!--数据--><el-form ref="form" :model="form" label-width="40px" size="mini"><el-form-item label="状态"><el-radio-group v-model="form.resource"><el-radio label="全部"></el-radio><el-radio label="查找"></el-radio><el-radio label="待审核"></el-radio><el-radio label="审核通过"></el-radio><el-radio label="审核失败"></el-radio><el-radio label="已删除"></el-radio></el-radio-group></el-form-item><el-form-item label="频道"><el-select v-model="form.region" placeholder="请选择频道"><el-option label="区域一" value="shanghai"></el-option><el-option label="区域二" value="beijing"></el-option></el-select></el-form-item><el-form-item label="日期"><el-date-pickerv-model="form.date1"type="datetime"placeholder="选择日期时间"align="right"></el-date-picker></el-form-item><el-form-item><el-button type="primary" @click="onSubmit">查询</el-button></el-form-item></el-form></el-card><el-card class="filter-card"><div slot="header" class="clearfix">根据筛选条件有1314520条结果</div><!--数据列表--><el-table:data="articals"style="width: 100%" stripe size="mini" ><el-table-columnprop="date"label="封面"></el-table-column><el-table-columnprop="title"label="标题"></el-table-column><el-table-columnprop="status"label="状态"><!--如果需要自定义遍历当前数据--><template slot-scope="scope"><el-tag v-if="scope.row.status===0">草稿</el-tag><el-tag v-else-if="scope.row.status===1">待审核</el-tag><el-tag v-else-if="scope.row.status===2" type="success">审核通过</el-tag><el-tag v-else-if="scope.row.status===3" type="danger">审核失败</el-tag><el-tag v-else-if="scope.row.status===4" type="info">已删除</el-tag></template></el-table-column><el-table-columnprop="pubdate"label="发布时间"></el-table-column><el-table-columnprop="cover"label="操作"><template><el-button size="mini" icon="el-icon-edit" type="primary" circle></el-button><el-button size="mini" icon="el-icon-delete" type="danger" circle></el-button></template></el-table-column></el-table><!--分页--><el-pagination class="list-table"layout="prev, pager, next":total="1000"></el-pagination></el-card></div>
</template>
<script>
import { getArtical } from '@/api/artical'export default {name: 'ArticalIndex',created () {this.loadArticals()},data () {return {form: {name: '',region: '',date1: '',date2: '',delivery: false,type: [],resource: '',desc: ''},articals: [] // 记录文章的数据}},methods: {onSubmit () {console.log('submit!')},loadArticals () {getArtical().then(res => {console.log(res)console.log(res)console.log(res)this.articals = res.data.data.results})}}
}</script>
<style scope lang="less">
.filter-card{margin-bottom: 30px;
}
.list-table{margin-bottom: 20px;
}
</style>

content--->index.vue

<template>
<div class="artical-container"><!--卡片--><el-card class="filter-card"><div slot="header" class="clearfix"><!--面包屑导航--><el-breadcrumb separator-class="el-icon-arrow-right"><el-breadcrumb-item :to="{ path: 'home' }">首页</el-breadcrumb-item><el-breadcrumb-item>首页管理</el-breadcrumb-item></el-breadcrumb></div><!--数据--><el-form ref="form" :model="form" label-width="40px" size="mini"><el-form-item label="状态"><el-radio-group v-model="status"><el-radio :label="null">全部</el-radio><el-radio :label="0">草稿</el-radio><el-radio :label="1">待审核</el-radio><el-radio :label="2">审核通过</el-radio><el-radio :label="3">审核失败</el-radio><el-radio :label="4">已删除</el-radio></el-radio-group></el-form-item><el-form-item label="频道"><el-select v-model="channelId" placeholder="请选择频道"><el-option label="全部" :value="null"></el-option><el-option :label="channel.name" :value="channel.id" v-for="(channel,index) in channels" :key="index"></el-option></el-select></el-form-item><el-form-item label="日期"><el-date-pickerv-model="rangeDate"type="datetimerange"placeholder="选择日期时间"align="right"format="yyyy-MM-dd"value-format="yyyy-MM-dd"></el-date-picker></el-form-item><el-form-item><el-button type="primary" :disabled="loading" @click="loadArticals(1)">查询</el-button></el-form-item></el-form></el-card><el-card class="filter-card"><div slot="header" class="clearfix">根据筛选条件有{{totalCount}}条结果</div><!--数据列表--><el-table:data="articals"style="width: 100%" stripe size="mini" ><el-table-columnprop="date"label="封面"v-loading="loading"><template slot-scope="scope"><img v-if="scope.row.cover.images[0]" :src="scope.row.cover.images[0]" class="artical-cover" alt=""><img v-else class="artical-cover" src="./pic_bg.png" alt=""></template></el-table-column><el-table-columnprop="title"label="标题"></el-table-column><el-table-columnprop="status"label="状态"><!--如果需要自定义遍历当前数据--><template slot-scope="scope"><el-tag :type="articalsStatus[scope.row.status].type">{{articalsStatus[scope.row.status].text}}</el-tag><!-- <el-tag v-else-if="scope.row.status===1">待审核</el-tag><el-tag v-else-if="scope.row.status===2" type="success">审核通过</el-tag><el-tag v-else-if="scope.row.status===3" type="danger">审核失败</el-tag><el-tag v-else-if="scope.row.status===4" type="info">已删除</el-tag>--></template></el-table-column><el-table-columnprop="pubdate"label="发布时间"></el-table-column><el-table-columnprop="cover"label="操作"><template slot-scope="scope"><el-button size="mini" icon="el-icon-edit" type="primary" circle></el-button><el-button size="mini" icon="el-icon-delete" type="danger" @click="onDeleteArtical(scope.row.id)" circle></el-button></template></el-table-column></el-table><!--分页--><el-pagination class="list-table"layout="prev, pager, next":total="totalCount" :page-size="pageSize":disabled="loading"@current-change="OnCurrentChange" ></el-pagination></el-card></div>
</template>
<script>
import {getArtical,deleteArtical,getArticalChannels
} from '@/api/artical'export default {name: 'ArticalIndex',created () {this.loadArticals(1)this.loadChannels()},data () {return {loading: true,form: {name: '',region: '',date1: '',date2: '',delivery: false,type: [],resource: '',desc: ''},status: null, // 状态为空 查询文章的状态totalCount: 0, // 初始数据pageSize: 20, // 每页大小articals: [], // 记录文章的数据channels: [],channelId: null, // 文章的频道rangeDate: null, // 日期数据articalsStatus: [{ status: 0, text: '草稿', type: 'info' },{ status: 1, text: '待审核', type: '' },{ status: 2, text: '审核通过', type: 'success' },{ status: 3, text: '审核失败', type: 'warning' },{ status: 4, text: '已删除', type: 'danger' }]}},methods: {// 文章删除onDeleteArtical (articleId) {this.$confirm('确认删除吗', '删除提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {/* 要删除的文章id */deleteArtical(articleId)}).catch(() => {this.$message({type: 'info',message: '已取消删除'})})},onSubmit () {console.log('submit!')},loadArticals (page = 1) {this.loading = truegetArtical({page,per_page: this.pageSize,status: this.status,channel_id: this.channelId,/**  */begin_pubdate: this.rangeDate ? this.rangeDate[0] : null,end_pubdate: this.rangeDate ? this.rangeDate[1] : null}).then(res => {const { results, total_count: totalCount } = res.data.datathis.totalCount = totalCountthis.articals = results// 关闭加载this.loading = false})},loadChannels () {getArticalChannels().then(res => {console.log(res)this.channels = res.data.data.channels})},OnCurrentChange (page) {this.loadArticals(page)}}
}</script>
<style scope lang="less">
.filter-card{margin-bottom: 30px;
}
.list-table{margin-bottom: 20px;
}
.artical-cover{width: 60px;background-size:cover;
}
</style>

publish-->index.vue

<template><div class="publish-container">发布文章</div>
</template>

运行结果

前端学习(2449):发布文章组件相关推荐

  1. 前端学习(2554):组件基础和组件注册

  2. 前端学习(1233):组件化开发思想

  3. 前端学习(1232):组件化开发开始

  4. 前端学习(2457):文章发布

    # 五.文章发布## 创建组件并配置路由1.创建 `src/views/publish/index.vue` 组件```html <template><div class=" ...

  5. 前端学习(2456):文章列表

    # 四.文章列表模块## 创建组件并配置路由1.创建 `src/views/article/index.vue````html <template><div class=" ...

  6. Halo 开源项目学习(四):发布文章与页面

    文章目录 基本介绍 管理员发布文章 用户端访问文章 元数据 自定义页面 基本介绍 博客最基本的功能就是让作者能够自由发布自己的文章,分享自己观点,记录学习的过程.Halo 为用户提供了发布文章和展示自 ...

  7. js固定表格行列_纯前端表格控件SpreadJS V14.0发布:组件化编辑器+数据透视表

    SpreadJS 是一款基于 HTML5 的纯前端表格控件,兼容 450 种以上的 Excel 公式,具备"高性能.跨平台.与 Excel 高度兼容"的产品特性,可为用户提供高度类 ...

  8. 27.blog前端-发布文章

    点击写文章,会跳转到该页面 点击右上角的发布,会弹出发布的对话框因此,我们要调用文章分类列表和文章标签列表的接口 以及如果是点击文字的编辑按钮进入该页面的话,还需要通过调用文章id获取文章详情的接口 ...

  9. autojs遍历当前页面所有控件_纯前端表格控件SpreadJS V14.0发布:组件化编辑器+数据透视表 - 葡萄城开发工具...

    SpreadJS 是一款基于 HTML5 的纯前端表格控件,兼容 450 种以上的 Excel 公式,具备"高性能.跨平台.与 Excel 高度兼容"的产品特性,可为用户提供高度类 ...

最新文章

  1. 虚拟主机众多用途你心仪哪一项?
  2. 【★】Web精彩实战之智能迷宫
  3. SpringMVC的数据响应-页面跳转-返回ModelAndView形式1(应用)
  4. Junit4 简单教程
  5. python搭建web服务器需要tomcat吗_如何快速学习网站基本搭建和服务器环境配置(LAMP/LNMP/Tomcat)?...
  6. 简单工厂(Simple Pattern)模式
  7. c语言算开方程序,C语言计算开方
  8. K3救砖,梅林刷回官方
  9. ECharts 全新大版本 4.0 正式发布!百度数据可视化实验室成立
  10. git提交代码至码云
  11. 北京智源人工智能研究院(BAAI)前沿报告——强化学习领域
  12. 服务器终端性能测试之MBW内存测试
  13. screenX与clientX区别
  14. 麦田守望者--走出软件作坊:三五个人十来条枪 如何成为开发正规军(四十三)
  15. 区块链金融中的python应用--LSM定价
  16. 百度云盘限速破解方式汇总
  17. 获取员工其当前的薪水比其manager当前薪水还高的相关信息
  18. 微信小程序 - 设置图片高度自适应(宽度固定)
  19. 只有你项目不到,Electron也可以开发视频播放器
  20. Gavin老师Transformer直播课感悟 - 基于Transformer的Rasa 3.x 内核解密之Fallback and Human Handoff全解(二十四)

热门文章

  1. 冒泡排序(Java版)
  2. 基于以太坊发布属于自己的数字货币(代币)完整版
  3. scrapy之内蒙古自治区环境保护厅
  4. Eclipse 下载 开源项目 maven依赖丢失和 Deployment Assembly 丢失
  5. 【转】C/S,B/S区别
  6. WebRTC音视频引擎研究(2)--VoiceEngine音频编解码器数据结构以及参数设置
  7. html标签默认属性值之margin;padding值
  8. java forward 修改请求参数_聊聊springboot session timeout参数设置
  9. java try catch陷阱_Java异常处理最佳实践及陷阱防范
  10. python 三维向量 交互_Blender实现Nature of Code1.5单位向量[Nature of Node 004]