VehicleWaybill.vue 36.4 KB
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 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 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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 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 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 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 478 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 507 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 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
<template>
    <div>
        <div>
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="主单号">
                    <el-input v-model="formInline.awba" placeholder="主单号"></el-input>
                </el-form-item>
                <el-form-item label="车号">
                    <el-input v-model="formInline.licenseno" placeholder="车号"></el-input>
                </el-form-item>
                <el-form-item>
                    <div class="block">
                        <span class="demonstration">日期</span>
                        <el-date-picker
                                v-model="value2"
                                type="daterange"
                                align="right"
                                unlink-panels
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                :picker-options="pickerOptions">
                        </el-date-picker>
                    </div>
                </el-form-item>
                <el-form-item label="">
                    <el-select v-model="formInline.remark2" placeholder="付款状态">
                        <el-option label="是" value="1"></el-option>
                        <el-option label="否" value="0"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getLists">查询</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type="success" @click="addVehicle">新增</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type="danger" @click="onPaidan">派单</el-button>
                </el-form-item>
                <el-form-item>
                    <el-form-item>
                        <el-upload
                            class="upload-demo"
                            action=""
                            :before-upload="beforeUpload"
                            :http-request="uploadFile"
                            :show-file-list="false"
                    >
                        <el-button size="small" type="primary">导入运单</el-button>
                    </el-upload>
                    </el-form-item>
                    <el-button type="success" @click="exportToExcel">导出 Excel</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div>
            <el-table
                    ref="multipleTable"
                    :data="tableData"
                    tooltip-effect="dark"
                    style="width: 100%"
                    @selection-change="handleSelectionChange">
                <el-table-column
                        type="selection"
                        width="55">
                </el-table-column>
                <el-table-column
                        prop="customer"
                        label="客户名称"
                        width="120">
                </el-table-column>
                <el-table-column
                        prop="taketime"
                        label="日期"
                        width="120">
                </el-table-column>
                <el-table-column
                        prop="orig"
                        label="始发地"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="dest"
                        label="目的地"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="licenseno"
                        label="车号"
                        width="90">
                    <template slot-scope="scope">
                        <a type="text" style="color: #409eff;text-decoration: underline" class="tableInline"
                           @click="getReCord(scope.row)">{{scope.row.licenseno}}</a>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="dispatch"
                        label="派单号"
                        width="150">
                    <template slot-scope="scope">
                        <router-link :to="{name:'派单记录', query:{jilu:scope.row}}">
                            <a>
                                {{scope.row.dispatch}}
                            </a>
                        </router-link>
                    </template>
                </el-table-column>
                <el-table-column
                        prop="awbh"
                        label="分单号"
                        width="140">
                </el-table-column>
                <el-table-column
                        prop="awba"
                        label="主单号"
                        width="110">
                </el-table-column>
                <el-table-column
                        prop="deststation"
                        label="目的港"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="pcs"
                        label="件数"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="weight"
                        label="毛重"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="feweight"
                        label="计费重量"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="vol"
                        label="体积"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="charge"
                        label="应收"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="remark1"
                        label="应付"
                        show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                        prop="remark2"
                        label="付款状态"
                        show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span v-if="scope.row.remark2==='1'" style="color: #5BB75B;font-weight: bolder">已付</span>
                        <span v-else style="font-weight: bolder;color: red">未付</span>
                    </template>
                </el-table-column>
                <el-table-column
                        fixed="right"
                        label="操作"
                        width="100">
                    <template slot-scope="scope">
                        <el-button @click="ediVehicle(scope.row)" type="text" size="small">编辑</el-button>
                        <el-button @click="delVehicleWaybill(scope.row.id)" type="text" size="small">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div>
            <div class="block">
                <el-row>
                    <el-col :span="14">
                        <el-pagination
                                @size-change="handleSizeChange"
                                @current-change="handleCurrentChange"
                                :current-page="formInline.pageNum"
                                :page-sizes="[20, 30, 40, 100]"
                                :page-size="formInline.pageSize"
                                layout="total, sizes, prev, pager, next, jumper"
                                :total="total">
                        </el-pagination>
                    </el-col>
                </el-row>
            </div>
        </div>
        <div>
            <el-dialog
                    :title="'车载运单'+textMap[dialogStatus]"
                    :visible.sync="dialogVisible"
                    width="75%"
                    :before-close="handleClose">
                <el-form :inline="true" label-width="80px" :model="submitForm"
                         class="demo-form-inline">
                    <el-form-item label="客户名称">
                        <el-select v-model="submitForm.customer"
                                   @click.native="getUsers"
                                   default-first-option
                                   :loading="loading" clearable placeholder="请选择"
                                   style="width: 157px">
                            <el-option
                                    v-for="item in usernames"
                                    :key="item.roleName"
                                    :label="item.roleName"
                                    :value="item.roleName"
                                    :disabled="item.disabled">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="日期">
                        <div class="block">
                            <el-date-picker
                                    style="width: 157px"
                                    v-model="submitForm.taketime"
                                    type="date"
                                    format="yyyy-MM-dd"
                                    placeholder="选择日期">
                            </el-date-picker>
                        </div>
                    </el-form-item>
                    <el-form-item label="始发地">
                        <el-input v-model="submitForm.orig" placeholder="始发地"></el-input>
                    </el-form-item>
                    <el-form-item label="目的地">
                        <el-input v-model="submitForm.dest" placeholder="目的地"></el-input>
                    </el-form-item>
                    <el-form-item label="车号">
                        <el-input v-model="submitForm.licenseno" placeholder="车号"></el-input>
                    </el-form-item>
                    <el-form-item label="派单号">
                        <el-input v-model="submitForm.dispatch" placeholder="派单号"></el-input>
                    </el-form-item>
                    <el-form-item label="分单号">
                        <el-input v-model="submitForm.awbh" placeholder="分单号"></el-input>
                    </el-form-item>
                    <el-form-item label="主单号">
                        <el-input v-model="submitForm.awba" placeholder="主单号"></el-input>
                    </el-form-item>
                    <el-form-item label="目的港">
                        <el-input v-model="submitForm.deststation" placeholder="目的港"></el-input>
                    </el-form-item>
                    <el-form-item label="件数">
                        <el-input v-model="submitForm.pcs" placeholder="件数"></el-input>
                    </el-form-item>
                    <el-form-item label="毛重">
                        <el-input v-model="submitForm.weight" placeholder="毛重"></el-input>
                    </el-form-item>
                    <el-form-item label="计费重量">
                        <el-input v-model="submitForm.feweight" placeholder="计费重量"></el-input>
                    </el-form-item>
                    <el-form-item label="体积">
                        <el-input v-model="submitForm.vol" placeholder="体积"></el-input>
                    </el-form-item>
                    <el-form-item label="应收">
                        <el-input v-model="submitForm.charge" placeholder="应收"></el-input>
                    </el-form-item>
                    <el-form-item label="应付">
                        <el-input v-model="submitForm.remark1" placeholder="应付"></el-input>
                    </el-form-item>
                    <el-form-item label="付款状态">
                        <el-select v-model="submitForm.remark2" style="width: 157px">
                            <el-option
                                    v-for="item in paystatus"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="危险品">
                        <el-select v-model="submitForm.isdangerous" style="width: 157px">
                            <el-option
                                    v-for="item in options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="尺寸">
                        <el-input v-model="submitForm.means" placeholder="尺寸"></el-input>
                    </el-form-item>
                    <el-form-item label="备注">
                        <el-input v-model="submitForm.remark" placeholder="备注"></el-input>
                    </el-form-item>

                </el-form>
                <span slot="footer" class="dialog-footer" style="margin-right: 50px">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="dialogStatus==='create'?addVehicleWaybill():ediVehicleWaybill()">确 定</el-button>
                </span>
            </el-dialog>
        </div>
        <div>
            <el-dialog
                    title="派单申请"
                    :visible.sync="PDdialogVisible"
                    width="30%"
                    :before-close="handleClose">
                <el-form :model="PDForm" :rules="rules" ref="PDForm" label-width="100px" :label-position="labelPosition"
                         class="demo-ruleForm">
                    <el-form-item label="车号" prop="licenseno">
                        <el-input v-model="PDForm.licenseno"></el-input>
                    </el-form-item>
                    <el-form-item label="派单号" prop="dispatch">
                        <el-input v-model="PDForm.dispatch"></el-input>
                    </el-form-item>
                    <el-form-item label="始发地" prop="orig">
                        <el-input v-model="PDForm.orig"></el-input>
                    </el-form-item>
                    <el-form-item label="目的地" prop="dest">
                        <el-input v-model="PDForm.dest"></el-input>
                    </el-form-item>
                    <el-form-item label="客户名称" prop="opter">
                        <el-select v-model="PDForm.opter"
                                   @click.native="getUsers2"
                                   default-first-option
                                   :loading="loading" clearable placeholder="请选择"
                                   style="width: 100%">
                            <el-option
                                    v-for="item in usernames2"
                                    :key="item.roleName"
                                    :label="item.roleName"
                                    :value="item.departmentid"
                                    :disabled="item.disabled">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="任务描述" prop="description">
                        <el-input type="textarea" v-model="PDForm.description"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitPDForm('PDForm')">派单</el-button>
                        <el-button @click="resetForm('PDForm')">取消</el-button>
                    </el-form-item>
                </el-form>

            </el-dialog>
        </div>
        <div>
            <el-dialog
                    :visible.sync="CardialogVisible"
                    width="65%"
                    :before-close="handleClose">
                <el-descriptions class="margin-top" title="车辆信息" :column="3" :size="size" border>
                    <template slot="extra">
                        <el-button type="primary" @click="CardialogVisible = false">关闭</el-button>
                    </template>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-user"></i>
                            司机
                        </template>
                        {{carinfo.veOwnerName}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-mobile-phone"></i>
                            手机号
                        </template>
                        {{carinfo.ownerInsideTel}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-truck"></i>
                            车号
                        </template>
                        {{carinfo.domesticLisenceNo}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-tickets"></i>
                            驾驶证有效期
                        </template>
                        <el-tag size="small">{{carinfo.veFactoryDate}}</el-tag>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-shopping-cart-full"></i>
                            车自重
                        </template>
                        {{carinfo.selfWt}}
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label">
                            <i class="el-icon-office-building"></i>
                            地址
                        </template>
                        {{carinfo.proposer}}
                    </el-descriptions-item>
                </el-descriptions>
            </el-dialog>
        </div>
    </div>
</template>
<script>
    import {
        getUserList,
        addVehicleWaybill,
        delVehicleWaybill,
        ediVehicleWaybill,
        selectNewInventroyrecords,
        paidan,
        UploadExcel
    } from "../../api/consigner/vehicle";
    import {list} from "../../api/road_verecord/verecord";
    import XLSX from 'xlsx';
    import { saveAs } from 'file-saver';
    import { getList as getCRMList } from '@/api/crm_api';

    export default {
        data() {
            return {
                size: 'medium',
                PDForm: {
                    licenseno: '',
                    orig: '',
                    dest: '',
                    dispatch: '',
                    description:'',
                    opter:''
                },
                rules: {
                    licenseno: [
                        {required: true, message: '请输入车号', trigger: 'blur'},
                        {min: 3, max: 15, message: '长度在 3 到 15 个字符', trigger: 'blur'}
                    ],
                    dispatch: [
                        {required: true, message: '请输入派单号', trigger: 'blur'},
                        {min: 3, max: 17, message: '长度在 3 到 17 个字符', trigger: 'blur'}
                    ],
                    orig: [
                        {required: true, message: '请输入始发地', trigger: 'blur'},
                        {min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur'}
                    ],
                    opter: [
                        {required: true, message: '请选择派单客户', trigger: 'blur'},
                        {min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur'}
                    ],
                    dest: [
                        {required: true, message: '请输入目的地', trigger: 'blur'},
                        {min: 2, max: 100, message: '长度在 3 到 100 个字符', trigger: 'blur'}
                    ],
                },
                labelPosition: 'left',
                tableData: [],
                multipleSelection: [],
                formInline: {
                    awba: '',
                    licenseno: '',
                    starttime: '',
                    remark2:'',
                    endtime: '',
                    pageNum: 1,
                    pageSize: 20
                },
                dialogStatus: '',
                loading: false,
                listLoading: false,
                value2: '',
                total: 0,
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                currentPage4: 4,
                submitForm: {
                    awba: "",
                    awbh: "",
                    charge: 0,
                    createtime: "",
                    customer: "",
                    dest: "",
                    deststation: "",
                    dispatch: "",
                    id: "",
                    isdangerous: 0,
                    licenseno: "",
                    means: "",
                    orig: "",
                    pcs: 0,
                    pic: "",
                    relevance: "",
                    remark: "",
                    remark1: "",
                    remark2: "0",
                    taketime: "",
                    vol: 0,
                    weight: 0,
                    feweight:0
                },
                dialogVisible: false,
                PDdialogVisible: false,
                CardialogVisible: false,
                usernames: [],
                options: [
                    {
                        value: 0,
                        label: '否'
                    }, {
                        value: 1,
                        label: '是'
                    }
                ],
                paystatus: [
                    {
                        value: "0",
                        label: '否'
                    }, {
                        value: "1",
                        label: '是'
                    }
                ],
                textMap: {
                    update: '编辑',
                    create: '新增'
                },
                carinfo: {
                    domesticLisenceNo: '',
                    veOwnerName: '',
                    ownerInsideTel: '',
                    proposer: '',
                    selfWt: '',
                    veFactoryDate: '',
                    veTon: '',
                    trailerLicenseNo: '',
                    trailerFrameNo: ''
                },
                usernames2: [],
            }
        },

        methods: {
            //导入运单excel
            beforeUpload(file) {
                // 检查文件类型
                const isExcel = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type === 'application/vnd.ms-excel';
                if (!isExcel) {
                    this.$message.error('上传文件只能是 Excel 格式!');
                    return false; // 取消文件上传
                }
                return true; // 允许上传

                },
            uploadFile({ file, onSuccess, onError }){
                // 生成 FormData 对象
                const formData = new FormData();
                formData.append('file', file);
                UploadExcel(formData).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error(res.msg);
                    }
                    this.$message.success(res.msg);
                    this.getLists();
                    onSuccess(response.data); // 调用 onSuccess 回调通知上传成功
                }).catch(error => {
                    // 关闭加载
                    this.$message.error(error.toString())
                    onError(error); // 调用 onError 回调通知上传失败
                })
            },
            //导出excel
            exportToExcel() {
                if(this.multipleSelection.length!==0){
                    const headers = {
                        customer: '客户名称',
                        taketime: '日期',
                        orig: '始发地',
                        dest: '目的地',
                        licenseno: '车号',
                        awba: '主单',
                        awbh: '分单',
                        deststation: '目的港',
                        pcs: '件数',
                        weight: '毛重',
                        vol: '体积',
                        means: '尺寸',
                        charge: '应收'
                    };

                    // Filter data to include only specified columns
                    const filteredData = this.multipleSelection.map(row => {
                        const newRow = {};
                        for (const key in headers) {
                            newRow[headers[key]] = row[key];
                        }
                        return newRow;
                    });

                    // Convert to worksheet and workbook
                    const ws = XLSX.utils.json_to_sheet(filteredData, { header: Object.values(headers) });
                    const wb = XLSX.utils.book_new();
                    XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
                    const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });

                    saveAs(new Blob([wbout], { type: 'application/octet-stream' }), new Date().toLocaleString()+'.xlsx');
                }else{
                    this.$message.warning('请先勾选要导出的数据!');
                }

            },
            //查询车牌号
            getReCord(row) {
                let para = {
                    pageSize: 1,
                    limitSize: 10,
                    trailerFrameNo: row.licenseno,
                    veState: '',
                    veClassFlag: '',
                    userId: ''
                };
                list(para).then((res) => {
                    if(res.data.data.list.length!==0){
                        this.carinfo = res.data.data.list[0];
                        this.CardialogVisible=true;
                    }else{
                        this.$message.warning('无对应车辆信息!')
                    }
                }).catch((error) => {
                    this.$message.warning('车辆查询,失败!')
                });
            },
            //提交派单表单申请
            submitPDForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.multipleSelection.forEach(item => {
                            item.licenseno = this.PDForm.licenseno;
                            item.orig = this.PDForm.orig;
                            item.dest = this.PDForm.dest;
                            item.dispatch = this.PDForm.dispatch;
                        });
                        const params = {
                            records: this.multipleSelection,
                            pdform: this.PDForm
                        };
                        paidan(params).then((response) => {
                            const res = response.data
                            if (res.code !== '200') {
                                return this.$message.error('车辆派单,失败!')
                            }
                            this.$message.success('车辆派单,成功!')
                            this.PDdialogVisible = false;
                        }).catch(error => {
                            // 关闭加载
                            this.$message.warning('车辆派单,失败!')
                        })
                    } else {
                        return false;
                    }
                });
            },
            //生成派单号
            getCurrentFormattedDate() {
                const now = new Date();
                const pad = (num) => num.toString().padStart(2, '0');

                const yyyy = now.getFullYear();
                const MM = pad(now.getMonth() + 1);
                const dd = pad(now.getDate());
                const HH = pad(now.getHours());
                const mm = pad(now.getMinutes());
                const ss = pad(now.getSeconds());
                const SSS = now.getMilliseconds().toString().padStart(3, '0');

                return `${yyyy}${MM}${dd}${HH}${mm}${ss}${SSS}`;
            },

            //派单取消提交
            resetForm(formName) {
                this.$refs[formName].resetFields();
                this.PDdialogVisible = false;
            },
            //更新车载运单
            ediVehicleWaybill() {
                ediVehicleWaybill(this.submitForm).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error('更新车载运单,失败!')
                    }
                    this.$message.success('更新车载运单,成功!')
                    this.dialogVisible = false;
                    this.getLists();
                }).catch(error => {
                    // 关闭加载
                    this.$message.warning('更新车载运单,失败!')
                })
            },
            //删除车载运单
            delVehicleWaybill(id) {
                // 弹框询问是否删除?
                this.$confirm('此操作永久删除该消息收发记录, 是否继续?', '警告', {
                        confirmButtonText: '确定删除',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }
                ).then(() => {
                    delVehicleWaybill({id: id}).then((response) => {
                        const res = response.data
                        this.$message.success(res.msg)
                        this.getLists();
                    }).catch(error => {
                        this.$message.error('删除车载运单,失败!')
                    })
                }).catch(() => {
                })
            },
            //新增车载运单
            addVehicleWaybill() {
                addVehicleWaybill(this.submitForm).then((response) => {
                    const res = response.data
                    if (res.code !== '200') {
                        return this.$message.error('新增车载运单,失败!')
                    }
                    this.$message.success('新增车载运单,成功!')
                    this.dialogVisible = false;
                    this.getLists();
                }).catch(error => {
                    // 关闭加载
                    this.$message.warning('新增车载运单,失败!')
                })
            },
            //查询列表
            getLists() {
                if (this.value2 !== null) {
                    this.formInline.starttime = this.value2[0];
                    this.formInline.endtime = this.value2[1];
                }
                selectNewInventroyrecords(this.formInline).then((response) => {
                    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('获取消息收发记录,成功!');
                    this.formInline.endtime = '';
                    this.formInline.starttime = '';
                }).catch(error => {
                    // 关闭加载
                    this.$message.error(error.toString())
                })
            },
            onPaidan() {
                if (this.multipleSelection.length !== 0) {
                    this.PDdialogVisible = true;
                    this.PDForm.dispatch = this.getCurrentFormattedDate();
                } else {
                    this.$message.error('请选勾取要派车的运单信息!');
                }
                this.getUsers2();
            },
            //新增
            addVehicle() {
                this.dialogVisible = true;
                this.dialogStatus = 'create';
                this.getUsers();
            },
            //编辑
            ediVehicle(row) {
                this.dialogVisible = true;
                this.dialogStatus = 'update';
                this.submitForm = row;
            },
            //翻页
            handleSizeChange(val) {
                this.formInline.pageSize = val;
                this.getLists();
            },
            handleCurrentChange(val) {
                this.formInline.pageNum = val;
                this.getLists();
            },
            //多选选中
            handleSelectionChange(val) {
                this.multipleSelection = val;
                console.log(this.multipleSelection)
            },
            //Dialog关闭提示
            handleClose(done) {
                this.$confirm('确认关闭?')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            //获取用户名列表
            getUsers() {
                let data = {orgtype: "",roleName:"",departmentid:""};
                let para={pageSize: 1000, pageNum: 1}
                this.listLoading = true;
                getUserList(data,para).then((res) => {
                    this.usernames = res.data.data.list;
                }).catch((error) => {
                    this.$message.error(error.toString());
                }).finally(() => {
                    this.listLoading = false;
                });
            },
            //获取用户名列表
            getUsers2() {
                let data = {orgtype: "",roleName:"",departmentid:""};
                let para={pageSize: 1000, pageNum: 1}
                this.listLoading = true;
                getUserList(data,para).then((res) => {
                    this.usernames2 = res.data.data.list;
                    console.log(this.usernames2)
                }).catch((error) => {
                    this.$message.error(error.toString());
                }).finally(() => {
                    this.listLoading = false;
                });
            },
        },
        mounted() {
            this.getLists();
        }
    }
</script>