kongdeqiang
2022-09-22 bb31220ccb1e5dbc7ba5498b306f32699185d3f8
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
    <div style="height: 500px;overflow: auto;">
        <div style="padding: 10px 10px 0px 10px;">
            <el-form :inline="true" :model="searchForm">
                <!--<el-form-item label="名称">-->
                    <!--<el-input v-model="searchForm.name"></el-input>-->
                <!--</el-form-item>-->
                <el-form-item>
                    <!--<el-button type="primary" size="small" @click="onSearch" icon="el-icon-search">查询</el-button>-->
                    <el-button type="primary" size="small" @click="onAdd" icon="el-icon-plus">增加</el-button>
                </el-form-item>
            </el-form>
        </div>
 
        <el-table :data="pageData.rows" v-loading="pageData.isLoading" border style="width:100%;margin-left: 3px;border:1px solid #bcbec2;margin-right: 5px;">
            <el-table-column type="index" width="50" label="序号" align="center"> </el-table-column>
            <el-table-column prop="name" label="名称" align="center"></el-table-column>
            <el-table-column prop="code" label="编号" align="center"></el-table-column>
            <el-table-column prop="code2" label="支付编号" align="center"></el-table-column>
            <el-table-column prop="status" label="连接状况" align="center">
                <template slot-scope="scope">
                    <p v-if="scope.row.status==0">正常</p>
                    <p v-if="scope.row.status==1" style="color: red">异常</p>
                </template>
            </el-table-column>
            <el-table-column prop="type" label="方位" align="center">
                <template slot-scope="scope">
                    <p v-if="scope.row.type==0">出</p>
                    <p v-if="scope.row.type==1">入</p>
                </template>
            </el-table-column>
            <el-table-column label="操作" fixed="right" width="250" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" @click="onEdit(scope.$index, scope.row)">编辑</el-button>
                    <el-button size="mini" type="danger" @click="onDelete(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="onPageSizeChange" @current-change="onCurrentPageChange" :current-page="pageData.currentPage" :page-size="pageData.pageSize" :total="pageData.total" style="float: right"></el-pagination>
 
        <el-dialog append-to-body title="编辑" :visible.sync="flag" width="40%">
            <el-form :model="formData" ref="formData" label-width="100px">
                <el-form-item label="道闸名称"  prop="name" :rules="[{required: true, message: '请输入道闸名称', trigger: 'blur'}]">
                    <el-input v-model="formData.name"></el-input>
                </el-form-item>
                <el-form-item label="道闸编号"  prop="code" :rules="[{required: true, message: '请输入道闸编号', trigger: 'blur'}]">
                    <el-input v-model="formData.code"></el-input>
                </el-form-item>
                <el-form-item label="支付编号"  prop="code2" :rules="[{required: true, message: '请输入支付编号', trigger: 'blur'}]">
                    <el-input v-model="formData.code2"></el-input>
                </el-form-item>
                <el-form-item label="方位" prop="type" :rules="[{required: true, message: '请选择方位', trigger: 'blur'}]">
                    <el-select v-model="formData.type">
                        <el-option label="出" :value=0></el-option>
                        <el-option label="入" :value=1></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="flag = false">取 消</el-button>
                <el-button type="primary" @click="onSave">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
 
<script>
    export default {
        name: "index",
        props:["id2"],
        data: function () {
            return {
                flag:false,
                flag2:false,
                searchForm: {
                    parkId: this.id2
                },
                pageData: this.$byutil.defaultPageData(),
                formData: {
                    name: '',
                    parkId: null,
                    type: '',
                    code:""
                },
                urlPath:this.$systemconfig.basePath + '/barrier/',
            }
        },
        watch:{
            id2(){
                this.loadData();
            }
        },
        mounted() {
            this.loadData();
        },
        methods: {
            onSave(){
                this.$refs['formData'].validate((valid) => {
                    if (valid) {
                        this.formData.parkId = this.id2;
                        this.$byutil.postData(this, this.urlPath+'save', this.formData, res => {
                            this.$refs['formData'].resetFields();
                            this.flag=false;
                            this.$message({message: res.message, type: 'success'});
                            this.loadData();
                        })
                    } else {
                        return false;
                    }
                });
            },
            loadData() {
                this.searchForm.parkId = this.id2
                this.$byutil.loadPageData(this, this.urlPath+'findPage', this.searchForm);
            },
            onSearch() {
                this.pageData = this.$byutil.defaultPageData();
                this.loadData();
            },
            onAdd() {
                this.flag=true;
                this.$refs['formData'].resetFields();
                this.formData = {
                    name: '',
                    parkId: null,
                    type: '',
                    code:''
                }
            },
            onEdit(index, row) {
                this.flag=true;
                this.formData  = row;
            },
            onDelete(index, row) {
                this.$byutil.deleteData(this,this.urlPath+"delete",{id:row.id}, res => {
                    this.$message({message: res.message, type: 'success'});
                    this.loadData();
                })
            },
            onPageSizeChange(val) {
                this.pageData.pageSize = val;
                this.loadData();
            },
            onCurrentPageChange(val) {
                this.pageData.page = val;
                this.loadData();
            },
            daoZha(row){
                alert(2)
                this.flag2 = true;
            }
        }
    }
</script>
 
<style scoped>
 
</style>