| | |
| | | url:'/news/fuzzy', |
| | | params:data, |
| | | }) |
| | | } |
| | | //添加新闻 |
| | | export const add = data => { |
| | | return request({ |
| | | method:'POST', |
| | | url:'/news/add', |
| | | params:data |
| | | }) |
| | | } |
| | |
| | | .flex-between{ |
| | | justify-content: space-between; |
| | | } |
| | | .flex-around{ |
| | | justify-content: space-around; |
| | | } |
| | | .fl{ |
| | | float: left; |
| | | } |
| | |
| | | <template> |
| | | <div class="box"> |
| | | 新闻标题:<el-input v-model="title" placeholder="请输入新闻标题"></el-input><br/><br/> |
| | | 发布日期:<el-input v-model="releaseTime" placeholder="请输入新闻发布日期"></el-input> |
| | | 发布日期:<el-date-picker v-model="releaseTime" placeholder="请选择新闻发布日期"></el-date-picker><br/><br/> |
| | | 新闻内容:<quill-editor ref="text" v-model="content" class="myQuillEditor" :options="editorOption" /> |
| | | <el-button type="primary" @click="submit">确定</el-button> |
| | | <el-button type="success">提交</el-button> |
| | | <div class="btn"> |
| | | <el-button type="success" @click="submit">发布</el-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import { add } from '../../api/api' |
| | | import { quillEditor } from 'vue-quill-editor' |
| | | import 'quill/dist/quill.core.css' |
| | | import 'quill/dist/quill.snow.css' |
| | |
| | | title:'', //标题内容 |
| | | releaseTime:'', //发布日期 |
| | | content: '', //新闻内容 |
| | | newsCategoryId:2, |
| | | editorOption: { |
| | | placeholder: "请输入正文", |
| | | // editorOption里是放图片上传配置参数用的,例如: |
| | | action: '/api/product/richtext_img_upload.do', // 必填参数 图片上传地址 |
| | | methods: 'POST', // 必填参数 图片上传方式 |
| | | token: '', // 可选参数 如果需要token验证,假设你的token有存放在sessionStorage |
| | | name: 'upload_file', // 必填参数 文件的参数名 |
| | | size: 10000000, // 可选参数 图片大小,单位为Kb, 1M = 1024Kb |
| | | accept: 'multipart/form-data, image/png, image/gif, image/jpeg, image/bmp, image/x-icon,image/jpg' // 可选 可上传的图片格式 |
| | | } , //编辑器新闻对象 |
| | | } |
| | | }, |
| | | created(){ |
| | | // console.log('>>>>>>>',this.$route.query.id); |
| | | this.newsCategoryId = this.$route.query.id |
| | | }, |
| | | methods:{ |
| | | submit () { |
| | | console.log(this.$refs.text.value) |
| | | submit(){ |
| | | const data = { |
| | | newsCategoryId:this.newsCategoryId, |
| | | content:this.content, |
| | | title:this.title, |
| | | releaseTime:this.releaseTime |
| | | } |
| | | add(data).then(res => { |
| | | console.log(res); |
| | | if(res.code !== 200){ |
| | | return this.$message.error('发布新闻失败,请重试!') |
| | | }else{ |
| | | this.$message.success('新闻发布成功!') |
| | | console.log(this.content); |
| | | this.$router.go(-1) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | |
| | | width: 1200px; |
| | | margin: 0 auto; |
| | | } |
| | | .myQuillEditor{ |
| | | height: 350px; |
| | | } |
| | | .btn{ |
| | | position: absolute; |
| | | bottom: 20px; |
| | | left: 168px; |
| | | } |
| | | </style> |
| | |
| | | <el-row :gutter="40"> |
| | | <el-col :span="4"> |
| | | <!-- 添加新闻按钮 --> |
| | | <el-button el-button class="add" type="success" icon="el-icon-plus" @click="goEdit()">点击在该列表下添加一条新闻</el-button> |
| | | <el-button el-button class="add" type="success" icon="el-icon-plus" @click="goEdit(newsCategoryId)">点击在该列表下添加一条新闻</el-button> |
| | | </el-col> |
| | | <el-col :span="10"> |
| | | <!-- 新闻搜索 --> |
| | |
| | | |
| | | </el-table-column> |
| | | </el-table> |
| | | <div class="fenye"> |
| | | <!-- 分页 --> |
| | | <div> |
| | | <!-- 获取新闻列表分页 --> |
| | | <div class="get"> |
| | | <div> |
| | | <el-pagination |
| | | v-show="getShow" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | :current-page="currentPage" |
| | | :page-sizes="[3,6,12, 18,]" |
| | | :page-sizes="[6,12, 18,]" |
| | | :page-size="100" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="total"> |
| | | </el-pagination> |
| | | </div> |
| | | <!-- 模糊新闻列表分页 --> |
| | | <div class="fuzzy"> |
| | | <div> |
| | | <el-pagination |
| | | v-show="fuzzyShow" |
| | | @size-change="handleSizeChangefuzzy" |
| | | @current-change="handleCurrentChangefuzzy" |
| | | :current-page="fuzzyForm.fuzzycurrent" |
| | |
| | | <el-input v-model="editForm.title"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="发布日期:"> |
| | | <el-input v-model="editForm.releaseTime"></el-input> |
| | | <!-- <el-input v-model="editForm.releaseTime"></el-input> --> |
| | | <el-date-picker v-model="editForm.releaseTime" type="date" placeholder="请选择发布日期"></el-date-picker> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | |
| | | |
| | | <script> |
| | | import { getNewsList,getnew,update,deleteNew,fuzzy } from '../../api/api' |
| | | import axios from 'axios' |
| | | export default { |
| | | data() { |
| | | return { |
| | | fuzzyShow:false, //模糊查询分页的显示(布尔值) |
| | | getShow:true, //获取分页的显示(布尔值) |
| | | visible: false, |
| | | editDialogVisible:false, //控制修改对话框的布尔值 |
| | | editForm:{}, //查询到的新闻对象,目前仅供修改使用 |
| | | newsCategoryId:1, //先存一个小标题id |
| | | tableData:[], //新闻列表对象 |
| | | pageSize:3, //每页条数 |
| | | pageSize:6, //每页条数 |
| | | currentPage:1, //当前页 |
| | | total:0, //新闻总条数 |
| | | fuzzyForm:{ fuzzytitle:'',fuzzytotal:0,fuzzycurrent:1,fuzzysize:6 }, //模糊查询列表对象 |
| | |
| | | }, |
| | | //级联选择器的方法 |
| | | handleChange(value) { |
| | | console.log(value); |
| | | console.log(value[1]); |
| | | // console.log(value); |
| | | // console.log(value[1]); |
| | | this.newsCategoryId = value[1]; //将得到的小标题id存放起来 |
| | | this.query(this.newsCategoryId); |
| | | }, |
| | |
| | | size:this.pageSize |
| | | }; |
| | | getNewsList(data).then(res=>{ |
| | | console.log(res); |
| | | // console.log(res); |
| | | if (res.code !== 200) { |
| | | return this.$message.error('获取新闻列表失败') |
| | | }else{ |
| | |
| | | //展示修改对话框 |
| | | showEditDialog(id){ |
| | | getnew(id).then(res => { |
| | | console.log(res); |
| | | // console.log(res); |
| | | if (res.code == 200) { |
| | | this.editForm = res.data |
| | | } |
| | |
| | | }, |
| | | //确定修改表单提交,验证发起请求 |
| | | editNew(){ |
| | | // console.log(typeof(this.editForm.releaseTime)); |
| | | // console.log(this.editForm.releaseTime); |
| | | let arr = this.editForm.releaseTime.split('') |
| | | if(arr[4] !== '/' || arr[7] !== '/'){ |
| | | return this.$message.error('请按照“XXXX/XX/XX”的格式填写日期') |
| | | }else{ |
| | | const data = { |
| | | id: this.editForm.id, |
| | | releaseTime: this.editForm.releaseTime, |
| | | title:this.editForm.title |
| | | } |
| | | update(data).then(res=>{ |
| | | console.log('dsadasas'+res); |
| | | if (res.code == 200) { |
| | | this.editDialogVisible =false; |
| | | this.$message.success('修改新闻成功!') |
| | | this.query(this.newsCategoryId); |
| | | } |
| | | }) |
| | | const data = { |
| | | id: this.editForm.id, |
| | | releaseTime: this.editForm.releaseTime, |
| | | title:this.editForm.title |
| | | } |
| | | update(data).then(res=>{ |
| | | // console.log('dsadasas',res); |
| | | if (res.code == 200) { |
| | | this.editDialogVisible =false; |
| | | this.$message.success('修改新闻成功!') |
| | | this.query(this.newsCategoryId); |
| | | } |
| | | }) |
| | | }, |
| | | //模糊查询 |
| | | fuzzyList(title){ |
| | | console.log(title); |
| | | // console.log(title); |
| | | if(title == ''){ |
| | | return this.$message.error('请先输入查询新闻标题!') |
| | | } |
| | | this.fuzzyShow = true //模糊分页显示 |
| | | this.getShow = false //获取分页隐藏 |
| | | const data = { |
| | | current: this.fuzzyForm.fuzzycurrent, |
| | | size: this.fuzzyForm.fuzzysize, |
| | | title:title |
| | | } |
| | | fuzzy(data).then(res => { |
| | | console.log(res); |
| | | // console.log(res); |
| | | if (res.code !== 200) { |
| | | return this.$message.error('查询新闻列表失败') |
| | | }else{ |
| | |
| | | qingKong(){ |
| | | this.tableData = [] |
| | | this.fuzzyForm.fuzzytotal = 0 |
| | | this.fuzzyShow = false |
| | | this.getShow = true |
| | | }, |
| | | //根据id删除新闻 |
| | | async deleteNews(id){ |
| | | console.log(id); |
| | | // console.log(id); |
| | | const res = await this.$confirm('此操作将永久删除该条新闻, 是否继续?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | |
| | | this.fuzzyList(this.fuzzyForm.fuzzytitle) //模糊查询 |
| | | }, |
| | | //去往添加编辑页面 |
| | | goEdit(){ |
| | | if (this.newsCategoryId==27||this.newsCategoryId==28||this.newsCategoryId==29|| |
| | | this.newsCategoryId==30||this.newsCategoryId==31) { |
| | | this.$message.error('该新闻标题下不能添加新闻') |
| | | }else if(this.newsCategoryId == 35||this.newsCategoryId==36||this.newsCategoryId==37|| |
| | | goEdit(id){ |
| | | if (this.newsCategoryId==27&&this.total==1||this.newsCategoryId==28&&this.total==1||this.newsCategoryId==29&&this.total==1|| |
| | | this.newsCategoryId==30&&this.total==1||this.newsCategoryId==31&&this.total==1) { |
| | | this.$message.error('该新闻标题下只能存在一篇新闻') |
| | | }else if(this.newsCategoryId==27||this.newsCategoryId==28||this.newsCategoryId==29||this.newsCategoryId==30|| |
| | | this.newsCategoryId==31||this.newsCategoryId == 35||this.newsCategoryId==36||this.newsCategoryId==37|| |
| | | this.newsCategoryId==38||this.newsCategoryId==39||this.newsCategoryId==40|| |
| | | this.newsCategoryId==41||this.newsCategoryId==42||this.newsCategoryId==43|| |
| | | this.newsCategoryId==44){ |
| | | this.$router.push('/administrator/edit') |
| | | this.$router.push({path:'/administrator/edit',query:{id:id}}) |
| | | console.log(this.newsCategoryId); |
| | | }else{ |
| | | this.$message.error('请先选择新闻标题') |
| | | } |
| | |
| | | .add{ |
| | | margin-bottom: 10px !important; |
| | | } |
| | | .block{ |
| | | margin-bottom: 10px; |
| | | } |
| | | .el-pagination{ |
| | | margin-top: 10px; |
| | | } |
| | | .fenye{ |
| | | display: flex; |
| | | justify-content: space-between; |
| | | } |
| | | </style> |
| | |
| | | // 1.2 token 只应在当前网站打开期间生效,所以将 token 保存在 sessionStorage 中 |
| | | window.sessionStorage.setItem('token', res.data.token) |
| | | // 2. 通过编程式导航跳转到后台主页,路由地址是 /home |
| | | this.$router.push('/administrator') |
| | | this.$router.push('/administrator/main') |
| | | }) |
| | | } |
| | | } |
| | |
| | | } |
| | | }, |
| | | created(){ |
| | | console.log(">>>>>>>>",this.$route.query.id); |
| | | // console.log(">>>>>>>>",this.$route.query.id); |
| | | this.getalone(); |
| | | // this.queryAll(); |
| | | }, |
| | | methods:{ |
| | | getalone(){ |
| | |
| | | this.title = res.data.title; |
| | | }) |
| | | }, |
| | | // queryAll(){ |
| | | // this.content = `` |
| | | // } |
| | | }, |
| | | } |
| | | </script> |
| | | <style> |
| | | h2{ |
| | | .header h2{ |
| | | color: rgb(3, 73, 144); |
| | | text-align: center; |
| | | } |
| | | p{ |
| | | .header p{ |
| | | background-color: rgb(246, 246, 246); |
| | | text-align: center; |
| | | height: 35px; |
| | |
| | | </el-col> |
| | | <!-- 新闻内容 --> |
| | | <el-card class="box-card"> |
| | | <el-col :span="18"> |
| | | <div>{{ this.new.content }}</div> |
| | | <el-col> |
| | | <div v-html="this.new.content"></div> |
| | | </el-col> |
| | | </el-card> |
| | | </el-row> |
| | |
| | | text-align: center; |
| | | } |
| | | } |
| | | .box-card{ |
| | | // background-color: rgb(131, 212, 115); |
| | | } |
| | | .ft-blue { |
| | | color: rgb(9, 143, 252); |
| | | } |
| | |
| | | <img src="../../assets/weiBo.jpg" alt=""> |
| | | </el-card> |
| | | </div> |
| | | <divc class="right"> |
| | | <div class="right"> |
| | | <el-table :data="tableData" border :header-cell-style="{textAlign: 'center'}" :cell-style="{ textAlign: 'center' }"> |
| | | <!-- :header-cell-style="{textAlign: 'center'}"设置头部居中: --> |
| | | <!-- :cell-style="{ textAlign: 'center' }"设置整个表格内容水平居中: --> |
| | |
| | | <el-table-column prop="mail" label="邮箱" width="200"> |
| | | </el-table-column> |
| | | </el-table> |
| | | </divc> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | | </div> |
| | |
| | | import Welcome from './components/Administrator/Welcome.vue' |
| | | import Main from './components/Administrator/Main.vue' |
| | | import Edit from './components/Administrator/Edit.vue' |
| | | import Update from './components/Administrator/Update.vue' |
| | | |
| | | |
| | | Vue.use(Router) |
| | |
| | | children: [{ path:'welcome',component:Welcome }, |
| | | { path:'main',component:Main }, |
| | | { path:'edit',component:Edit }, |
| | | { path:'news',component:News }, |
| | | { path:'update',component:Update }] |
| | | { path:'news',component:News },] |
| | | }, |
| | | { |
| | | path: '/home', |
| | |
| | | currentPagenotice:1, //通知公告的当前页 |
| | | currentPageschool:1, //学院动态的当前页 |
| | | currentPagework:1, //工作动态的当前页 |
| | | pageSize:4, |
| | | pageSize:10, |
| | | totalnotice:0, //通知公告新闻的总条数 |
| | | totalschool:0, //学院动态新闻的总条数 |
| | | totalwork:0, //工作动态新闻的总条数 |
| | |
| | | border-bottom: 1px solid #0f99e9; |
| | | } |
| | | .lieBiao { |
| | | width: 95%; |
| | | width: 100%; |
| | | height: 60px; |
| | | background: rgb(241, 241, 241); |
| | | margin-bottom: 10px; |
| | |
| | | .time { |
| | | width: 100px; |
| | | padding: 17px 0px; |
| | | display: flex; |
| | | flex-direction: column; |
| | | background-color: rgb(1, 72, 153); |
| | | color: white; |
| | | text-align: center; |
| | | } |
| | | .title { |
| | | width: 550px; |
| | | width: 980px; |
| | | height: 50px; |
| | | overflow: hidden; |
| | | line-height: 60px; |
| | |
| | | padding: 0 0 0 10px; |
| | | } |
| | | .ul{ |
| | | width: 700px; |
| | | margin: 0 auto; |
| | | width: 1100px; |
| | | margin: 0; |
| | | } |
| | | </style> |