charles
2024-05-06 bad4f431d9287c31da042ada125910e9b3e8c3b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<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>