审查视图

src/views/deploy/area.vue 28.5 KB
1 2 3 4
<template>
    <el-row>
        <el-card  style="background-color: #F5F7FA">
            <!--            搜索区域-->
5
            <el-row :gutter="5" class="toolbar">
6 7 8 9 10 11 12
                <el-col :span="7">
                    <el-input v-model="queryInfo.areano" prefix-icon="el-icon-search" size="small" style="width: 280px"
                              placeholder="场站编号" clearable>
                        <template slot="prepend">库区编号</template>
                    </el-input>
                </el-col>
                <el-col :span="6">
13 14 15 16 17 18
                    <el-input v-model="queryInfo.houseid" prefix-icon="el-icon-search" size="small" style="width: 280px"
                              placeholder="仓库编号" clearable>
                        <template slot="prepend">仓库编号</template>
                    </el-input>
                </el-col>
                <el-col :span="6">
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
                    <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>
                </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"
34
                            @row-dblclick="tableRowClick"
35 36 37 38 39
                    >
                        <el-table-column
                                fixed
                                prop="areano"
                                label="库区编号"
小范 authored
40
                                width="140">
41 42
                        </el-table-column>
                        <el-table-column
43
                                prop="areaname"
44
                                label="库区名称"
小范 authored
45
                                width="140">
46 47 48 49
                        </el-table-column>
                        <el-table-column
                                prop="houseid"
                                label="所属仓库"
小范 authored
50
                                width="120">
51
                        </el-table-column>
52 53 54 55 56 57 58 59 60 61
<!--                        <el-table-column-->
<!--                                prop="length"-->
<!--                                label="库区长度"-->
<!--                                width="80">-->
<!--                        </el-table-column>-->
<!--                        <el-table-column-->
<!--                                prop="width"-->
<!--                                label="库区宽度"-->
<!--                                width="80">-->
<!--                        </el-table-column>-->
62 63 64 65 66
                        <el-table-column
                                prop="areanum"
                                label="库区面积"
                                width="80">
                        </el-table-column>
67 68 69 70 71
<!--                        <el-table-column-->
<!--                                prop="areavol"-->
<!--                                label="库区体积"-->
<!--                                width="80">-->
<!--                        </el-table-column>-->
72 73 74
                        <el-table-column
                                prop=" owner"
                                label="分配货主"
小范 authored
75
                                width="120">
76 77 78 79
                        </el-table-column>
                        <el-table-column
                                prop="surpluslocation"
                                label="剩余库位"
小范 authored
80
                                width="80">
81 82 83
                        </el-table-column>
                        <el-table-column
                                prop="totallocation"
84
                                label="占用库位">
85
                        </el-table-column>
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
<!--                        <el-table-column-->
<!--                                prop="xstart"-->
<!--                                label="库区X起始位"-->
<!--                                width="90">-->
<!--                        </el-table-column>-->
<!--                        <el-table-column-->
<!--                                prop="xend"-->
<!--                                label="库区X结束位"-->
<!--                                width="90">-->
<!--                        </el-table-column>-->
<!--                        <el-table-column-->
<!--                                prop="ystart"-->
<!--                                label="库区Y起始位"-->
<!--                                width="90">-->
<!--                        </el-table-column>-->
<!--                        <el-table-column-->
<!--                                prop="yend"-->
<!--                                label="库区Y结束位"-->
<!--                                width="90">-->
<!--                        </el-table-column>-->
<!--                        <el-table-column-->
<!--                                prop="zstart"-->
<!--                                label="库区Z起始位"-->
<!--                                width="90">-->
<!--                        </el-table-column>-->
<!--                        <el-table-column-->
<!--                                prop="zend"-->
<!--                                label="库区Z结束位"-->
<!--                                width="90">-->
<!--                        </el-table-column>-->
116 117
                        <el-table-column
                                fixed="right"
小范 authored
118 119
                                label="操作"
                                width="200">
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
                            <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>
                <el-dialog :title="dialogMap[dialogApply]" :visible.sync="apply_dialog.addDialog" width="80%" >
                    <el-form  :model="addForm"  :rules="rules" ref="addForm" style="margin-top: 40px">
                        <el-row>
143
                            <el-col :span="12">
144
                                <el-form-item label="" :label-width="formLabelWidth"  prop="houseid">
145 146
                                    <div class="my-text-area">
                                        <div class="el-input-group__prepend prepand">所属仓库</div>
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
                                        <el-select v-model="addForm.houseid" v-if="this.dis === 'create'"
                                                   filterable
                                                   allow-create
                                                   default-first-option
                                                   remote  size="small"
                                                   :remote-method="getHouseid"
                                                   :loading="loading" placeholder="请输入所属仓库" style="width: 210px">
                                            <el-option
                                                    v-for="item in houseids"
                                                    :key="item.houseid"
                                                    :label="item.housename"
                                                    :value="item.houseid">
                                                <span style="float: left">{{ item.housename }}</span>
                                                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.houseid }}</span>
                                            </el-option>
                                        </el-select>
                                        <el-select v-model="addForm.houseid" v-else disabled
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
                                                   filterable
                                                   allow-create
                                                   default-first-option
                                                   remote  size="small"
                                                   :remote-method="getHouseid"
                                                   :loading="loading" placeholder="请输入所属仓库" style="width: 210px">
                                            <el-option
                                                    v-for="item in houseids"
                                                    :key="item.houseid"
                                                    :label="item.housename"
                                                    :value="item.houseid">
                                                <span style="float: left">{{ item.housename }}</span>
                                                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.houseid }}</span>
                                            </el-option>
                                        </el-select>
                                    </div>
180 181
                                </el-form-item>
                            </el-col>
182 183 184
                        </el-row>
                        <el-row>
                            <el-col :span="7">
185
                                <el-form-item label="" :label-width="formLabelWidth"  prop="areano">
186 187 188 189
                                    <el-input v-if="this.dis === 'create'" v-model="addForm.areano" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区编号</template>
                                    </el-input>
                                    <el-input v-else disabled v-model="addForm.areano" autocomplete="off" size="small" style="width: 300px">
190 191 192 193 194 195 196 197 198 199 200
                                        <template slot="prepend">库区编号</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="areaname">
                                    <el-input v-model="addForm.areaname" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区名称</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
201 202 203 204 205 206 207
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="totallocation">
                                    <el-input v-model="addForm.totallocation" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">占用库位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
                        </el-row>
                        <el-row>
                            <el-col :span="7">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="length">
                                    <el-input v-model="addForm.length" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区长度</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="width">
                                    <el-input v-model="addForm.width" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区宽度</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="areanum">
                                    <el-input v-model="addForm.areanum" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区面积</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="7">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="areavol">
                                    <el-input v-model="addForm.areavol" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区体积</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="owner">
                                    <el-input v-model="addForm.owner" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">分配货主</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="surpluslocation">
                                    <el-input v-model="addForm.surpluslocation" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">剩余库位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="7">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="xstart">
                                    <el-input v-model="addForm.xstart" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区X起始位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="xend">
                                    <el-input v-model="addForm.xend" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区X结束位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
270
                            <el-col :span="8">
271 272 273 274 275 276
                                <el-form-item label="" :label-width="formLabelWidth"  prop="ystart">
                                    <el-input v-model="addForm.ystart" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区Y起始位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
277 278 279
                        </el-row>
                        <el-row>
                            <el-col :span="7">
280 281 282 283 284 285 286 287 288 289 290 291 292
                                <el-form-item label="" :label-width="formLabelWidth"  prop="yend">
                                    <el-input v-model="addForm.yend" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区Y结束位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="" :label-width="formLabelWidth"  prop="zstart">
                                    <el-input v-model="addForm.zstart" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区Z起始位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
293
                            <el-col :span="8">
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
                                <el-form-item label="" :label-width="formLabelWidth"  prop="zend">
                                    <el-input v-model="addForm.zend" autocomplete="off" size="small" style="width: 300px">
                                        <template slot="prepend">库区Z结束位</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="apply_dialog.addDialog = false" size="small">取 消</el-button>
                        <el-button type="primary" @click="dialogApply==='create'?add():edit()" size="small">提 交</el-button>
                    </div>
                </el-dialog>
            </el-row>
        </el-card>
309 310 311 312 313 314
        <el-dialog title="库位" :visible.sync="dialogVisible" fullscreen >
            <LOCATIONS :parent-area-id="selectedAreaId" />
            <span slot="footer" class="dialog-footer">
                <el-button type="info" @click="dialogVisible = false">关 闭</el-button>
            </span>
        </el-dialog>
315 316 317 318
    </el-row>
</template>

<script>
319 320 321 322 323 324 325
    import {
        selectAreas,
        delArea,
        addArea,
        ediArea,
        selectByHouseid
    } from '../../api/consigner/station';
326
    import jsutil from "@/common/js/util";
327
    import LOCATIONS from "./locations"
328 329

    export default {
330
        // name: "area",
331
        props:['parentHouseId'],
332
        components:{LOCATIONS},
333 334 335
        data() {
            return {
                queryInfo: {
336
                    houseid:'',
337
                    areano:'',
338
                    // areaName:'',
339 340 341 342 343 344 345 346 347 348 349 350
                    // 当前页数
                    pageNum: 1,
                    // 每页大小
                    pageSize: 10,
                },
                total: 0,
                tableData:[],
                dialogMap: {
                    update: '编辑',
                    create: '新增'
                },
                dialogApply: 'create',
351
                dis: undefined,
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
                apply_dialog: {
                    // 添加对话框
                    addDialog: false,
                    // 编辑对话框
                    editDialog: false
                },
                addForm: {
                    areaname: '',
                    areano: '',
                    areanum: '',
                    areavol: '',
                    houseid: '',
                    length: '',
                    owner: '',
                    surpluslocation: '',
                    totallocation: '',
                    width: '',
                    xend: '',
                    xstart: '',
                    yend: '',
                    ystart: '',
                    zend: '',
                    zstart: '',
                    remark:'',
                    remark1:'',
                    remark2:'',
                    remark3:'',
                    remark4:'',
                },
381 382 383
                houseids:[],
                houseid: '',
                loading:false,
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
                formLabelWidth: '120px',
                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' },
                        // ],
                    ],
                },
404 405
                dialogVisible:false,
                selectedAreaId:""
406 407 408
            }
        },
        methods: {
409 410 411 412 413 414 415 416 417 418 419 420 421
            //获取所属仓库
            getHouseid:function(query){
                this.houseids=[];
                this.loading = true;
                selectByHouseid({houseid:query}).then(res =>{
                    if (res !== '') {
                        setTimeout(() => {
                            this.houseids=res.data.data;
                        }, 200);
                    } else {
                        this.houseids = [];
                    }
422 423
                }).finally(() =>{
                    this.loading = false;
424 425
                });
            },
426 427 428 429 430 431 432 433 434 435
            handleSizeChange(val) {
                this.queryInfo.pageSize = val
                this.getList()
            },
            handleCurrentChange(val) {
                this.queryInfo.pageNum = val
                this.getList()
            },
            getList() {
                const _this = this
436 437
                selectAreas(_this.queryInfo).then((response) => {
                    console.log("查询参数:",this.queryInfo)
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
                    const res = response.data
                    if (res.code !== '200') {
                        return _this.$message.error('获取消息收发记录,失败!')
                    }
                    // 获取列表数据
                    _this.tableData = res.data.list
                    // 获取列表的总记录数
                    _this.total = res.data.total
                    _this.$message.success('获取消息收发记录,成功!')
                }).catch(error => {
                    // 关闭加载
                    _this.$message.error(error.toString())
                })
            },
            // 添加对话框,打开事件
            applyAdd() {
                this.addForm = {
                    areaname: '',
                    areano: '',
                    areanum: '',
                    areavol: '',
                    houseid: '',
                    length: '',
                    owner: '',
                    surpluslocation: '',
                    totallocation: '',
                    width: '',
                    xend: '',
                    xstart: '',
                    yend: '',
                    ystart: '',
                    zend: '',
                    zstart: '',
                    remark:'',
                    remark1:'',
                    remark2:'',
                    remark3:'',
                    remark4:'',
                };
                this.dialogApply= 'create';
478
                this.dis= 'create';
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
                this.apply_dialog.addDialog = true;
            },
            // 添加功能
            add() {
                this.$refs.addForm.validate(valid => {
                    // 未通过,表单预校验
                    if (!valid) return;
                    addArea(this.addForm).then((response) => {
                        let res = response.data;
                        // 添加失败
                        if (res.code !== '200') {
                            return this.$message.error(res.msg);
                        }
                        // 添加,成功
                        this.$message.success(res.msg);
                        // 隐藏对话框
                        this.apply_dialog.addDialog = false;
                        // 刷新列表
                        this.getList();
                    }).catch(error => {
                        this.$message.error(error.toString());
                    });
                })
            },
// 打开编辑
            applyEdit(row) {
                this.apply_dialog.addDialog = true;
                this.dialogApply = 'update';
507
                this.dis= 'update';
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
                this.addForm=row;
            },
            // 编辑功能
            edit() {
                // 进行表单的预验证
                this.$refs.addForm.validate(valid => {
                    // 未通过,表单预校验
                    if (!valid) return
                    ediArea(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)
                        // 隐藏对话框
                        this.apply_dialog.addDialog = false
                        // 刷新列表
                        this.getList()
                    }).catch(error => {
                        this.$message.error(error.toString())
                    })
                })
            },
            // 删除
            applyDel(index, row) {
                // 弹框询问是否删除?
                this.$confirm('此操作永久删除该消息收发记录, 是否继续?', '警告', {
                        confirmButtonText: '确定删除',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }
                ).then(() => {
                    // console.log(row);
                    delArea({areano:row.areano}).then((response) => {
                        // console.log(row)
                        const res = response.data
                        this.$message.success(res.msg)
                        this.getList()
                    }).catch(error => {
                        this.$message.error(res.msg)
                    })
                }).catch(() => {
                })
            },
553 554 555 556 557 558
            //行点击事件
            tableRowClick(row, column, event) {
                this.dialogVisible = true
                this.selectedAreaId = row.areano
                // console.log(row+column,event);
            }
559 560
        },
        mounted() {
561 562 563
            if (jsutil.checkNull(this.parentHouseId)){
                this.queryInfo.houseid = this.parentHouseId;
            }
564
            this.getList();
565
        },
566
567 568
        watch: {
            parentHouseId(value) {
朱兆平 authored
569 570
                if (jsutil.checkNull(value)){
                    this.queryInfo.houseid = value;
571 572 573
                }
                this.getList();
            }
574 575 576 577 578 579 580 581 582 583 584 585 586 587
        }
    }
</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;
    }
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
    .my-text-area .prepand{
        float: left;
        width:89px;
        height: 28px;
        font-size: 12px;
        line-height: 28px;
    }
</style>
<style>
    .my-text-area .el-textarea__inner{
        min-height: 28px;
        height: 28px;
        border-bottom-left-radius: 0;
        border-top-left-radius: 0;
    }
603 604
</style>