<template>
|
<div>
|
<!--添加的模态框-->
|
<el-dialog
|
title="添加"
|
:visible.sync="addModal"
|
width="40%"
|
:close-on-click-modal="false"
|
@close="addModal=false"
|
:destroy-on-close="true"
|
>
|
<el-form ref="textForm" class="demo-form-inline" label-width="120px" :model="textObj" :rules="textRules">
|
<el-form-item label="文字内容:" prop="textContent">
|
<el-input v-model="textObj.textContent" placeholder="请输入文字内容"/>
|
</el-form-item>
|
<el-form-item label="车号:">
|
<el-input v-model="textObj.carNo" placeholder="请输入车号"/>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="addModal = false">取 消</el-button>
|
<el-button type="primary" @click="addText">确 定</el-button>
|
</span>
|
</el-dialog>
|
<div class="search">
|
<el-row type="flex" justify="center">
|
<el-col :span="18">
|
<el-form :inline="true" class="demo-form-inline">
|
<el-form-item label="文字内容/车号:">
|
<el-input v-model="keyword" size="small" placeholder="请输入"></el-input>
|
</el-form-item>
|
<el-form-item>
|
<el-button @click="searchCar" size="mini" type="primary" style="border:none;background-color: rgba(24, 144, 255, 1)">查询</el-button>
|
</el-form-item>
|
</el-form>
|
</el-col>
|
<el-col :span="6" style="text-align: right">
|
<el-button size="mini" @click="addModal=true" type="primary" style="border:none;background-color: rgba(24, 144, 255, 1)">添加</el-button>
|
</el-col>
|
</el-row>
|
</div>
|
<div>
|
<el-table :data="pageInfo.textList" >
|
<el-table-column prop="id" label="序号" align="center" />
|
<el-table-column prop="textContent" label="文字内容" align="center" />
|
<el-table-column prop="cid" label="车号" align="center" />
|
<el-table-column prop="date" label="添加时间" align="center" />
|
</el-table>
|
<div class="pagination">
|
<div class="total">共计{{pageInfo.total}}条记录 第{{pageData.page}}/{{lastPage}}页</div>
|
<div class="page">
|
<el-pagination
|
background
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page.sync="pageData.page"
|
:page-size="pageData.pageSize"
|
layout="prev, pager, next,sizes, jumper"
|
:total="pageInfo.total">
|
</el-pagination>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
name: "textManager",
|
data(){
|
return{
|
textRules:{
|
textContent: [
|
{ required: true, message: '内容不能为空', trigger: 'blur' },
|
],
|
},
|
addModal:false,
|
keyword:'',
|
textObj:{textContent:'',carNo:''},
|
pageInfo:{
|
total:100,
|
textList:[]
|
},
|
pageData:{page:1,pageSize:10}
|
}
|
},
|
computed:{
|
lastPage(){
|
return Math.ceil(this.pageInfo.total/this.pageData.pageSize)
|
}
|
},
|
methods:{
|
searchCar(){
|
//搜索
|
this.pageInfo.textList=[
|
{id:1, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:2, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:3, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:4, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:5, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:6, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:7, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:8, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:9, textContent: '火车启动', cid: 'k12', date: '2016-05-02'},
|
{id:10, textContent: '火车启动', cid: 'k12', date: '2016-05-02'}
|
];
|
},
|
handleSizeChange(pageSize){
|
this.pageData.pageSize=pageSize;
|
},
|
handleCurrentChange(page){
|
this.pageData.page=page;
|
},
|
addText(){
|
this.$refs.textForm.validate((valid) => {
|
if(valid){
|
|
}
|
})
|
}
|
},
|
mounted(){
|
this.searchCar();
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.pagination{
|
display: flex;
|
justify-content: space-between;
|
margin-top: 30px;
|
.total{
|
color: gray;
|
}
|
}
|
</style>
|