审查视图

src/views/deploy/station.vue 16.0 KB
1 2 3 4 5 6 7 8 9 10 11
<template>
    <el-row>
        <el-card  style="background-color: #F5F7FA">
            <!--            搜索区域-->
            <el-row :gutter="10" class="toolbar">
                <el-col :span="7">
                    <el-input v-model="queryInfo.stationno" prefix-icon="el-icon-search" size="small" style="width: 280px"
                              placeholder="场站编号" clearable>
                        <template slot="prepend">场站编号</template>
                    </el-input>
                </el-col>
12
                <el-col :span="9">
13 14 15 16
                    <el-button type="primary" icon="el-icon-search" size="small" @click="getList()">
                        查询
                    </el-button>
                    <el-button type="success" icon="el-icon-edit" size="small" @click="applyAdd()">新增</el-button>
17 18 19
                    <el-button type="primary" icon="el-icon-search" size="small" @click="getStationList()">
                        查询所有
                    </el-button>
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
                </el-col>
            </el-row>
            <!--            列表区域-->
            <el-row>
                <template>
                    <el-table
                            :data="tableData"
                            border
                            :cell-style="{textAlign:'center'}"
                            style="border-radius: 10px 10px 0px 0px;line-height: 25px"
                            :header-cell-style="{background:'#6F8294',color:'#FFFFFF'}" size="small"
                    >
                        <el-table-column
                                fixed
                                prop="stationno"
                                label="场站编号"
                                width="160">
                        </el-table-column>
                        <el-table-column
                                prop="stationname"
                                label="场站名称"
                                width="160">
                        </el-table-column>
                        <el-table-column
                                prop="stationadr"
                                label="场站地址"
                                width="240">
                        </el-table-column>
                        <el-table-column
                                prop="stationuser"
                                label="场站负责人名称"
                                width="120">
                        </el-table-column>
                        <el-table-column
                                prop="area"
                                label="区域代码"
                                width="160">
                        </el-table-column>
                        <el-table-column
                                prop="customs"
                                label="关区"
                                width="80">
                        </el-table-column>
                        <el-table-column
                                fixed="right"
                                label="操作">
                            <template slot-scope="scope">
                                <el-button type="success" size="mini" @click="applyEdit(scope.row)">编辑</el-button>
                                <el-button type="danger" size="mini" @click="applyDel(scope.$index,scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </template>
            </el-row>
            <el-row style="margin-top: 10px" class="toolbar">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="queryInfo.pageNum"
                        :page-size="queryInfo.pageSize"
                        :page-sizes="[10, 50, 100, 500]"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </el-row>
            <el-row>
86
                <el-dialog :title="dialogMap[dialogApply]" :visible.sync="apply_dialog" width="70%" >
87 88 89
                    <el-form  :model="addForm"  :rules="rules" ref="addForm" style="margin-top: 40px">
                        <el-row>
                            <el-col :span="9">
90
                                <el-form-item label="" :label-width="formLabelWidth"  prop="stationno">
91 92 93 94
                                    <el-input v-if="this.dis === 'create'" v-model="addForm.stationno" autocomplete="off" size="small" style="width: 260px">
                                        <template slot="prepend">场站编号</template>
                                    </el-input>
                                    <el-input v-else disabled v-model="addForm.stationno" autocomplete="off" size="small" style="width: 260px">
95 96
                                        <template slot="prepend">场站编号</template>
                                    </el-input>
97 98 99
                                </el-form-item>
                            </el-col>
                            <el-col :span="9">
100 101 102 103
                                <el-form-item label="" :label-width="formLabelWidth"  prop="stationname">
                                    <el-input v-model="addForm.stationname" autocomplete="off" size="small" style="width: 260px">
                                        <template slot="prepend">场站名称</template>
                                    </el-input>
104 105 106 107 108
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="9">
109 110
                                <el-form-item label="" :label-width="formLabelWidth"  prop="stationadr">
                                    <el-input v-model="addForm.stationadr" autocomplete="off" size="small" style="width: 260px">
小范 authored
111
                                        <template slot="prepend">场站地址</template>
112
                                    </el-input>
113 114 115
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
116 117 118 119
                                <el-form-item label="" :label-width="formLabelWidth" prop="stationuser">
                                    <el-input v-model="addForm.stationuser" autocomplete="off" size="small" style="width: 260px">
                                        <template slot="prepend">负责人名称</template>
                                    </el-input>
120 121 122 123 124
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="9">
125 126 127 128
                                <el-form-item label="" :label-width="formLabelWidth"  prop="area">
                                    <el-input v-model="addForm.area" autocomplete="off" size="small" style="width: 260px">
                                        <template slot="prepend">区域代码</template>
                                    </el-input>
129 130 131
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
132 133 134 135
                                <el-form-item label="" :label-width="formLabelWidth"  prop="customs">
                                    <el-input v-model="addForm.customs" autocomplete="off" size="small" style="width: 260px">
                                        <template slot="prepend">关&emsp;&emsp;区</template>
                                    </el-input>
136 137 138 139 140
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
141
                        <el-button @click="apply_dialog = false" size="small">取 消</el-button>
142 143 144 145 146 147 148 149 150
                        <el-button type="primary" @click="dialogApply==='create'?add():edit()" size="small">提 交</el-button>
                    </div>
                </el-dialog>
            </el-row>
        </el-card>
    </el-row>
</template>

<script>
151
    import {selectStations,delStation,addStation,ediStation,selectStationList} from '../../api/consigner/station';
152 153

    export default {
154
        name: "station",
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
        data() {
            return {
                queryInfo: {
                    stationno:'',
                    // 当前页数
                    pageNum: 1,
                    // 每页大小
                    pageSize: 10,
                },
                total: 0,
                tableData:[],
                dialogMap: {
                    update: '编辑',
                    create: '新增'
                },
170
                dis: undefined,
171
                dialogApply: 'create',
172
                apply_dialog: false,
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
                addForm: {
                    stationno: '',
                    stationname: '',
                    stationadr: '',
                    stationuser: '',
                    area: '',
                    customs: '',
                    remark:'',
                    remark1:'',
                    remark2:'',
                    remark3:''
                },
                formLabelWidth: '220px',
                rules: {
                    userName: [
                    //     { required: true, message: '请输入申请人', trigger: 'blur' },
                    //     // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
                    // ],
                    // applyTime: [
                    //     {  required: true, message: '请选择时间', trigger: 'change' }
                    // ],
                    // needCount: [
                    //     { required: true, message: '请输入需要车辆数量', trigger: 'blur' },
                    // ],
                    // orginStation: [
                    //     { required: true, message: '请输入起始场站', trigger: 'blur' },
                    // ],
                    // endStation: [
                    //     { required: true, message: '请输入目的场站', trigger: 'blur' },
                    // ],
                    ],
                },
            }
        },
        methods: {
            handleSizeChange(val) {
                this.queryInfo.pageSize = val
                this.getList()
            },
            handleCurrentChange(val) {
                this.queryInfo.pageNum = val
                this.getList()
            },
            getList() {
                const _this = this
                selectStations(this.queryInfo).then((response) => {
                    const res = response.data
                    console.log(response.data)
                    if (res.code !== '200') {
                        return _this.$message.error('获取消息收发记录,失败!')
                    }
                    // 获取列表数据
                    _this.tableData = res.data.list
                    // 获取列表的总记录数
                    _this.total = res.data.total
                    _this.$message.success('获取消息收发记录,成功!')
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
                }).catch(error => {
                    // 关闭加载
                    _this.$message.error(error.toString())
                })
            },
            getStationList() {
                const _this = this
                selectStationList(this.queryInfo).then((response) => {
                    const res = response.data
                    console.log(response.data)
                    if (res.code !== '200') {
                        return _this.$message.error('获取消息收发记录,失败!')
                    }
                    // 获取列表数据
                    _this.tableData = res.data.list
                    // 获取列表的总记录数
                    _this.total = res.data.total
                    _this.$message.success('获取消息收发记录,成功!')
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
                }).catch(error => {
                    // 关闭加载
                    _this.$message.error(error.toString())
                })
            },
            // 添加对话框,打开事件
            applyAdd() {
                this.addForm = {
                    stationno: '',
                    stationname: '',
                    stationadr: '',
                    stationuser: '',
                    area: '',
                    customs: '',
                    remark:'',
                    remark1:'',
                    remark2:'',
                    remark3:''
                };
                this.dialogApply= 'create';
267 268
                this.dis= 'create';
                this.apply_dialog = true;
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
            },
            // 添加功能
            add() {
                this.$refs.addForm.validate(valid => {
                    // 未通过,表单预校验
                    if (!valid) return;
                    addStation(this.addForm).then((response) => {
                        let res = response.data;
                        // 添加失败
                        if (res.code !== '200') {
                            return this.$message.error(res.msg);
                        }
                        // 添加,成功
                        this.$message.success(res.msg);
                        // 隐藏对话框
284
                        this.apply_dialog = false;
285 286 287 288 289 290 291 292 293
                        // 刷新列表
                        this.getList();
                    }).catch(error => {
                        this.$message.error(error.toString());
                    });
                })
            },
// 打开编辑
            applyEdit(row) {
294
                this.apply_dialog = true;
295
                this.dialogApply = 'update';
296
                this.dis= 'update';
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
                this.addForm=row;
            },
            // 编辑功能
            edit() {
                // 进行表单的预验证
                this.$refs.addForm.validate(valid => {
                    // 未通过,表单预校验
                    if (!valid) return
                    ediStation(this.addForm).then((response) => {
                        // console.log(row)
                        const res = response.data
                        if (res.code != '200') {
                            return this.$message.error(res.msg)
                        }
                        this.$message.success(res.msg)
                        // 隐藏对话框
313
                        this.apply_dialog = false
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
                        // 刷新列表
                        this.getList()
                    }).catch(error => {
                        this.$message.error(error.toString())
                    })
                })
            },
            // 删除
            applyDel(index, row) {
                // 弹框询问是否删除?
                this.$confirm('此操作永久删除该消息收发记录, 是否继续?', '警告', {
                        confirmButtonText: '确定删除',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }
                ).then(() => {
                    // console.log(row);
                    delStation({stationno:row.stationno}).then((response) => {
                        // console.log(row)
                        const res = response.data
                        this.$message.success(res.msg)
                        this.getList()
                    }).catch(error => {
                        this.$message.error(res.msg)
                    })
                }).catch(() => {
                })
            },
        },
        mounted() {
            this.getList();
            // this.getYardList();

        }

    }
</script>

<style scoped>
    .toolbar{
        height: 60px;
        background-color: white;
        /*line-height: 60px;*/
        vertical-align: middle;
        border-radius: 5px 5px 5px 5px;
        padding: 15px 0 0 20px;
        box-shadow: 0px 5px 5px #e5e8eb;
    }
</style>