info.vue 33.6 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 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
<template>
  <div class="app-container">

    <!-- 添加或修改处理场所管理对话框 -->
    <h3>
      基础信息
    </h3>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px"  label-position="top">
      <el-row :gutter="30">
        <el-col :span="7">
          <el-form-item label="姓名" prop="name">
            <el-input v-model="form.name" placeholder="请输入姓名" />
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="身份证号码" prop="identityCard">
            <el-input v-model="form.identityCard" placeholder="请输入身份证" :maxlength="18" show-word-limit/>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="手机号码" prop="phoneNo">
            <el-input v-model="form.phoneNo" placeholder="请输入手机号码"  :maxlength="11" show-word-limit/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="30">


        <el-col :span="7">
          <el-form-item label="从业资格证有效期起" prop="professionalQualificationBeginDate">
            <el-date-picker clearable size="small" style="width: 100%"
                            v-model="form.professionalQualificationBeginDate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择从业资格证有效期起">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="从业资格证有效期终" prop="professionalQualificationEndDate">
            <el-date-picker clearable size="small" style="width: 100%"
                            v-model="form.professionalQualificationEndDate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择从业资格证有效期终">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="所属公司" prop="companyId">
            <el-select v-model="form.companyId" placeholder="请选择所属公司" clearable style="width: 100%;" :disabled="form.id != null">
              <el-option v-for="(item,index) in enterpriseList" :label="item.name" :value="item.id" :key="index"/>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="30">
        <el-col :span="7">
          <el-form-item label="驾驶证有效期起" prop="drivingLicenceBeginDate">
            <el-date-picker clearable size="small" style="width: 100%"
                            v-model="form.drivingLicenceBeginDate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择驾驶证有效期起">
            </el-date-picker>
          </el-form-item>


        </el-col>
        <el-col :span="7">
          <el-form-item label="驾驶证有效期终" prop="drivingLicenceEndDate">
            <el-date-picker clearable size="small" style="width: 100%"
                            v-model="form.drivingLicenceEndDate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择驾驶证有效期终">
            </el-date-picker>
          </el-form-item>

        </el-col>
        <el-col :span="7">
            <el-row>
              <el-col :span="8">
                <el-form-item label="安全教育培训日期" prop="safetyTrainingDate">
                  <el-date-picker clearable size="small" style="width: 100%"
                                  v-model="form.safetyTrainingDate"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="选择日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="安全教育培训内容">
                  <el-input  v-model="form.safetyTrainingContent"  placeholder="请输入内容"/>
                </el-form-item>
              </el-col>
            </el-row>
        </el-col>
      </el-row>

      <el-row :gutter="30">
        <el-col :span="14">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="border: 1px solid #dcdfe6;border-radius: 2px;">
        <el-col :span="3">
          <div class="upload_lable">
            <span style="color:red;">*</span>驾驶证
            <el-upload
              ref="upload"
              action=""
              accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx"
              :on-change="fileChange"
              :auto-upload="false"
              :show-file-list="false"
              multiple
              :file-list="drivingLicence">

              <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button>
            </el-upload>
          </div>
        </el-col>
        <el-col :span="21">
          <div class="upload_btn">
            <div v-for="(item,index) in drivingLicence">
              <div v-if="!/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_image">
                <div class="upload_close" @click="drivingLicence.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <el-image
                  style="width: 110px; height: 95px; margin: 5px;float:left;"
                  :src="createUrl(item)"
                  :preview-src-list="[createUrl(item)]"
                  :z-index="999">
                </el-image>
              </div>
              <div  v-if="/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_file">
                <div class="upload_close_file" @click="drivingLicence.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <span @click="tempDownload(item)"><el-icon class="el-icon-document-add" style="font-size:70px;"></el-icon></span>
                <div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" @click="tempDownload(item)">{{ item.name }}</div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row style="border: 1px solid #dcdfe6;border-radius: 2px;">
        <el-col :span="3">
          <div class="upload_lable">
            <span style="color:red;">*</span>从业资格证
            <el-upload
              ref="upload"
              action=""
              accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx"
              :on-change="fileChange1"
              :auto-upload="false"
              :show-file-list="false"
              multiple
              :file-list="professionalQualification">
              <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button>
            </el-upload>
          </div>
        </el-col>
        <el-col :span="21">
          <div class="upload_btn">
            <div v-for="(item,index) in professionalQualification">
              <div v-if="!/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_image">
                <div class="upload_close" @click="professionalQualification.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <el-image
                  style="width: 110px; height: 95px; margin: 5px;float:left;"
                  :src="createUrl(item)"
                  :preview-src-list="[createUrl(item)]"
                  :z-index="999">
                </el-image>
              </div>
              <div  v-if="/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_file">
                <div class="upload_close_file" @click="professionalQualification.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <span @click="tempDownload(item)"><el-icon class="el-icon-document-add" style="font-size:70px;"></el-icon></span>
                <div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" @click="tempDownload(item)">{{ item.name }}</div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row style="border: 1px solid #dcdfe6;border-radius: 2px;">
        <el-col :span="3">
          <div class="upload_lable">
            <span style="color:red;">*</span>安全教育培训结业证明
            <el-upload
              ref="upload"
              action=""
              accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx"
              :on-change="fileChange2"
              :auto-upload="false"
              :show-file-list="false"
              multiple
              :file-list="safetyTraining">
              <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button>
            </el-upload>
          </div>
        </el-col>
        <el-col :span="21">
          <div class="upload_btn">
            <div v-for="(item,index) in safetyTraining">
              <div v-if="!/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_image">
                <div class="upload_close" @click="safetyTraining.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <el-image
                  style="width: 110px; height: 95px; margin: 5px;float:left;"
                  :src="createUrl(item)"
                  :preview-src-list="[createUrl(item)]"
                  :z-index="999">
                </el-image>
              </div>
              <div  v-if="/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_file">
                <div class="upload_close_file" @click="safetyTraining.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <span @click="tempDownload(item)"><el-icon class="el-icon-document-add" style="font-size:70px;"></el-icon></span>
                <div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" @click="tempDownload(item)">{{ item.name }}</div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row style="border: 1px solid #dcdfe6;border-radius: 2px;">
        <el-col :span="3">
          <div class="upload_lable">
            <span style="color:red;">*</span>一寸免冠照片1
            <el-upload
              ref="upload"
              action=""
              accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx"
              :on-change="fileChange3"
              :auto-upload="false"
              :show-file-list="false"
              multiple
              :file-list="photographOne">
              <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button>
            </el-upload>
          </div>
        </el-col>
        <el-col :span="21">
          <div class="upload_btn">
            <div v-for="(item,index) in photographOne">
              <div v-if="!/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_image">
                <div class="upload_close" @click="photographOne.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <el-image
                  style="width: 110px; height: 95px; margin: 5px;float:left;"
                  :src="createUrl(item)"
                  :preview-src-list="[createUrl(item)]"
                  :z-index="999">
                </el-image>
              </div>
              <div  v-if="/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_file">
                <div class="upload_close_file" @click="photographOne.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <span @click="tempDownload(item)"><el-icon class="el-icon-document-add" style="font-size:70px;"></el-icon></span>
                <div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" @click="tempDownload(item)">{{ item.name }}</div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <el-row style="border: 1px solid #dcdfe6;border-radius: 2px;">
        <el-col :span="3">
          <div class="upload_lable">
            <span style="color:red;">*</span>一寸免冠照片2
            <el-upload
              ref="upload"
              action=""
              accept=".jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx"
              :on-change="fileChange4"
              :auto-upload="false"
              :show-file-list="false"
              multiple
              :file-list="photographTwo">
              <el-button size="small" type="primary" icon="el-icon-upload">上传附件</el-button>
            </el-upload>
          </div>
        </el-col>
        <el-col :span="21">
          <div class="upload_btn">
            <div v-for="(item,index) in photographTwo">
              <div v-if="!/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_image">
                <div class="upload_close" @click="photographTwo.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <el-image
                  style="width: 110px; height: 95px; margin: 5px;float:left;"
                  :src="createUrl(item)"
                  :preview-src-list="[createUrl(item)]"
                  :z-index="999">
                </el-image>
              </div>
              <div  v-if="/\.(pjp|pdf|doc|docx|xls|xlsx)$/.test(item.name)" class="upload_div_file">
                <div class="upload_close_file" @click="photographTwo.splice(index,1);"><el-icon class="el-icon-error"></el-icon></div>
                <span @click="tempDownload(item)"><el-icon class="el-icon-document-add" style="font-size:70px;"></el-icon></span>
                <div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" @click="tempDownload(item)">{{ item.name }}</div>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="margin-top: 20px">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </div>
</template>

<script>
import { listDriver, getDriver, delDriver, addDriver, updateDriver, exportDriver } from "@/api/unit/driver";
import { listEnterprise} from "@/api/unit/enterprise";
import Treeselect from "@riophae/vue-treeselect";
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {getAreaList} from "@/api/casefile/remoteServer";
import Editor from "@/components/Editor/index.vue";

export default {
  name: "DisposalSite",
  components: {Editor, Treeselect},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 处理场所管理表格数据
      disposalSiteList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          {required: true, message: "请输入姓名", trigger: "blur"}
        ],
        identityCard: [
          {required: true, message: "请输入身份证号码", trigger: "blur"},
        ],
        companyId: [
          {required: true, message: "请选择所属公司", trigger: "blur"}
        ],
        drivingLicenceBeginDate: [
          {required: true, message: "请选择驾驶证有效期起", trigger: "blur"}
        ],
        drivingLicenceEndDate: [
          {required: true, message: "请选择驾驶证有效期终", trigger: "blur"}
        ],
        professionalQualificationBeginDate: [
          {required: true, message: "请选择从业资格证有效期起", trigger: "blur"}
        ],
        professionalQualificationEndDate: [
          {required: true, message: "请选择从业资格证有效期终", trigger: "blur"}
        ],
        safetyTrainingDate: [
          {required: true, message: "请选择安全教育培训日期", trigger: "blur"}
        ],
        safetyTrainingContent: [
          {required: true, message: "请输入安全教育培训内容", trigger: "blur"}
        ],
        phoneNo: [
          {required: true, message: "请输入手机号码", trigger: "blur"},
          {
            pattern: /^1(3|4|5|6|7|8|9)\d{9}$/,
            message: '手机号格式错误',
            trigger: 'change'
          }
        ],
      },
      areas:[],
      drivingLicence:[],
      professionalQualification:[],
      safetyTraining:[],
      photographOne:[],
      photographTwo:[],
      enterpriseList:[]
    };
  },
  created() {
    getAreaList().then(res => {
      this.areas = res.data;
    });
    this.queryParams = {
      companyType:"1"
    }
    listEnterprise(this.queryParams).then(response => {
      this.enterpriseList = response.rows;
    });
    this.initData();
  },
  watch: {
    '$route.query.driverInfoId': 'initData'
  },
  methods: {
    reset(){
      this.form = {};
      this.drivingLicence = [];
      this.professionalQualification = [];
      this.safetyTraining = [];
      this.photographOne = [];
      this.photographTwo = [];
    },
    initData(){
      this.reset();
      let id = this.$route.query.driverInfoId;
      console.log(id)
      if(id!=null){
        getDriver(id).then(response => {
          this.form = response.data;
          //将附件转换为前端可视化数组
          if(this.form.drivingLicence!=null&&this.form.drivingLicence!==""){
            let roadTransport = this.form.drivingLicence.split(";");
            roadTransport.map(item=>{
              let name = item.substring(item.lastIndexOf("/")+1);
              this.drivingLicence.push({name:name,url:item})
            })
          }
          if(this.form.professionalQualification!=null&&this.form.professionalQualification!==""){
            let drivingLicense = this.form.professionalQualification.split(";");
            drivingLicense.map(item=>{
              let name = item.substring(item.lastIndexOf("/")+1);
              this.professionalQualification.push({name:name,url:item})
            })
          }
          if(this.form.safetyTraining!=null&&this.form.safetyTraining!==""){
            let carFront = this.form.safetyTraining.split(";");
            carFront.map(item=>{
              let name = item.substring(item.lastIndexOf("/")+1);
              this.safetyTraining.push({name:name,url:item})
            })
          }
          if(this.form.photographOne!=null&&this.form.photographOne!==""){
            let carLeft = this.form.photographOne.split(";");
            carLeft.map(item=>{
              let name = item.substring(item.lastIndexOf("/")+1);
              this.photographOne.push({name:name,url:item})
            })
          }
          if(this.form.photographTwo!=null&&this.form.photographTwo!==""){
            let carBehind = this.form.photographTwo.split(";");
            carBehind.map(item=>{
              let name = item.substring(item.lastIndexOf("/")+1);
              this.photographTwo.push({name:name,url:item})
            })
          }
        });
      }
    },
    createUrl(file){
      if(file.raw!=null){
        return URL.createObjectURL(file.raw);
      }else{
        return process.env.VUE_APP_BASE_API + file.url;
      }

    },
    tempDownload(row){
      let name = row.name;
      let url = "";
      if(row.raw!=null){
        url = URL.createObjectURL(row.raw);
      }else{
        url = process.env.VUE_APP_BASE_API + row.url;
      }
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', url);
      a.click()
    },
    // 取消按钮
    cancel() {
      this.$tab.closePage({path:"/driverInfo/info"}).then(() => {
        this.$tab.openPage("驾驶员管理", "/tool/driver",{driverInfoRefresh:1})
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if(this.drivingLicence.length===0){
          this.$message({
            message: '请上传驾驶证!',
            type: 'warning'
          });
          return false;
        }
        if(this.professionalQualification.length===0){
          this.$message({
            message: '请上传从业资格证!',
            type: 'warning'
          });
          return false;
        }
        if(this.safetyTraining.length===0){
          this.$message({
            message: '请上传安全教育培训结业证明!',
            type: 'warning'
          });
          return false;
        }
        if(this.photographOne.length===0){
          this.$message({
            message: '请上传一寸免冠照片1!',
            type: 'warning'
          });
          return false;
        }
        if(this.photographTwo.length===0){
          this.$message({
            message: '请上传一寸免冠照片2!',
            type: 'warning'
          });
          return false;
        }
        if(this.form.professionalQualificationBeginDate>this.form.professionalQualificationEndDate){
          this.$message({
            message: '从业资格证有效期终不能小于从业资格证有效期起!',
            type: 'warning'
          });
          return false;
        }
        if(this.form.drivingLicenceBeginDate>this.form.drivingLicenceEndDate){
          this.$message({
            message: '驾驶证有效期终不能小于驾驶证有效期起!',
            type: 'warning'
          });
          return false;
        }
        if (valid) {
          let formData = new FormData();
          let form = this.form;
          //去掉params属性
          delete form.params;

          //先清空原有的附件
          form.drivingLicence = null;
          form.professionalQualification = null;
          form.safetyTraining = null;
          form.photographOne = null;
          form.photographTwo = null;
          //将附件拼接到form中
          this.drivingLicence.forEach(item => {
            if (item.raw != null) {
              formData.append('drivingLicenceFiles', item.raw)
            }else{
              //将原有的附件拼接到form中
              form.drivingLicence = form.drivingLicence!==null?form.drivingLicence+";"+item.url:item.url;
            }
          })
          this.professionalQualification.forEach(item => {
            if (item.raw != null) {
              formData.append('professionalQualificationFiles', item.raw)
            }else{
              //将原有的附件拼接到form中
              form.professionalQualification = form.professionalQualification!==null?form.professionalQualification+";"+item.url:item.url;
            }
          })
          this.safetyTraining.forEach(item => {
            if (item.raw != null) {
              formData.append('safetyTrainingFiles', item.raw)
            }else{
              //将原有的附件拼接到form中
              form.safetyTraining = form.safetyTraining!==null?form.safetyTraining+";"+item.url:item.url;
            }
          })
          this.photographOne.forEach(item => {
            if (item.raw != null) {
              formData.append('photographOneFiles', item.raw)
            }else{
              //将原有的附件拼接到form中
              form.photographOne = form.photographOne!==null?form.photographOne+";"+item.url:item.url;
            }
          })
          this.photographTwo.forEach(item => {
            if (item.raw != null) {
              formData.append('photographTwoFiles', item.raw)
            }else{
              //将原有的附件拼接到form中
              form.photographTwo = form.photographTwo!==null?form.photographTwo+";"+item.url:item.url;
            }
          })

          for (let key in form) {
            formData.append(key, form[key] == null ? "" : form[key])
          }
          if (this.form.id != null) {
            updateDriver(formData).then(response => {
              this.msgSuccess("修改成功");
              this.$tab.closePage({path:"/driverInfo/infoEdit"}).then(() => {
                this.$tab.openPage("驾驶员管理", "/tool/driver",{driverInfoRefresh:1})
              })
            });
          } else {
            addDriver(formData).then(response => {
              this.msgSuccess("新增成功");
              this.$tab.closePage({path:"/driverInfo/info"}).then(() => {
                this.$tab.openPage("驾驶员管理", "/tool/driver",{driverInfoRefresh:1})
              })
            });
          }
        }
      });
    },
    /**
     * 文件改变时,限制文件上传格式和大小
     * 文件格式只能为docx/doc/pdf/png/jpeg/png/jpg
     * 大小不超过20M
     * */
    fileChange(file, fileList) {
      let count = 0;
      for (let i = 0; i < fileList.length; i++) {
        // console.log(fileList.length)
        // console.log(this.fileEntityList[i].name+"111"+file.name)
        if (fileList[i].name == file.name) {
          count++;
          if (count == 2) {
            this.$message({
              message: '已存在此文件!',
              type: 'warning'
            });
            for (let j = fileList.length; j > 0; j--) {
              //如果存在此文件,去除新选择的重复文件
              if (fileList[j - 1].name == file.name) {
                fileList.splice(j - 1, 1);
                i--;
                return false;
              }
            }
          }
        }
      }
      let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
      //格式符合后判断大小
      if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx".indexOf(fileType) != -1) {
        let max5M = file.size / 1024 / 1024 < 100;
        if (!max5M) {
          this.$message({
            message: '上传文件大小不得超过100M!',
            type: 'warning'
          });
          fileList = fileList.splice(fileList.length - 1, 1);
        } else {
          //符合条件后进行添加
          this.drivingLicence = fileList
        }
      } else {
        this.$message({
          message: '上传文件只能是.jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx格式!',
          type: 'warning'
        });
        fileList = fileList.splice(fileList.length - 1, 1);
      }
    },
    fileChange1(file, fileList) {
      let count = 0;
      for (let i = 0; i < fileList.length; i++) {
        // console.log(fileList.length)
        // console.log(this.fileEntityList[i].name+"111"+file.name)
        if (fileList[i].name == file.name) {
          count++;
          if (count == 2) {
            this.$message({
              message: '已存在此文件!',
              type: 'warning'
            });
            for (let j = fileList.length; j > 0; j--) {
              //如果存在此文件,去除新选择的重复文件
              if (fileList[j - 1].name == file.name) {
                fileList.splice(j - 1, 1);
                i--;
                return false;
              }
            }
          }
        }
      }
      let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
      //格式符合后判断大小
      if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx".indexOf(fileType) != -1) {
        let max5M = file.size / 1024 / 1024 < 100;
        if (!max5M) {
          this.$message({
            message: '上传文件大小不得超过100M!',
            type: 'warning'
          });
          fileList = fileList.splice(fileList.length - 1, 1);
        } else {
          //符合条件后进行添加
          this.professionalQualification = fileList
        }
      } else {
        this.$message({
          message: '上传文件只能是.jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx格式!',
          type: 'warning'
        });
        fileList = fileList.splice(fileList.length - 1, 1);
      }
    },
    fileChange2(file, fileList) {
      let count = 0;
      for (let i = 0; i < fileList.length; i++) {
        // console.log(fileList.length)
        // console.log(this.fileEntityList[i].name+"111"+file.name)
        if (fileList[i].name == file.name) {
          count++;
          if (count == 2) {
            this.$message({
              message: '已存在此文件!',
              type: 'warning'
            });
            for (let j = fileList.length; j > 0; j--) {
              //如果存在此文件,去除新选择的重复文件
              if (fileList[j - 1].name == file.name) {
                fileList.splice(j - 1, 1);
                i--;
                return false;
              }
            }
          }
        }
      }
      let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
      //格式符合后判断大小
      if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx".indexOf(fileType) != -1) {
        let max5M = file.size / 1024 / 1024 < 100;
        if (!max5M) {
          this.$message({
            message: '上传文件大小不得超过100M!',
            type: 'warning'
          });
          fileList = fileList.splice(fileList.length - 1, 1);
        } else {
          //符合条件后进行添加
          this.safetyTraining = fileList
        }
      } else {
        this.$message({
          message: '上传文件只能是.jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx格式!',
          type: 'warning'
        });
        fileList = fileList.splice(fileList.length - 1, 1);
      }
    },
    fileChange3(file, fileList) {
      let count = 0;
      for (let i = 0; i < fileList.length; i++) {
        // console.log(fileList.length)
        // console.log(this.fileEntityList[i].name+"111"+file.name)
        if (fileList[i].name == file.name) {
          count++;
          if (count == 2) {
            this.$message({
              message: '已存在此文件!',
              type: 'warning'
            });
            for (let j = fileList.length; j > 0; j--) {
              //如果存在此文件,去除新选择的重复文件
              if (fileList[j - 1].name == file.name) {
                fileList.splice(j - 1, 1);
                i--;
                return false;
              }
            }
          }
        }
      }
      let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
      //格式符合后判断大小
      if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx".indexOf(fileType) != -1) {
        let max5M = file.size / 1024 / 1024 < 100;
        if (!max5M) {
          this.$message({
            message: '上传文件大小不得超过100M!',
            type: 'warning'
          });
          fileList = fileList.splice(fileList.length - 1, 1);
        } else {
          //符合条件后进行添加
          this.photographOne = fileList
        }
      } else {
        this.$message({
          message: '上传文件只能是.jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx格式!',
          type: 'warning'
        });
        fileList = fileList.splice(fileList.length - 1, 1);
      }
    },
    fileChange4(file, fileList) {
      let count = 0;
      for (let i = 0; i < fileList.length; i++) {
        // console.log(fileList.length)
        // console.log(this.fileEntityList[i].name+"111"+file.name)
        if (fileList[i].name == file.name) {
          count++;
          if (count == 2) {
            this.$message({
              message: '已存在此文件!',
              type: 'warning'
            });
            for (let j = fileList.length; j > 0; j--) {
              //如果存在此文件,去除新选择的重复文件
              if (fileList[j - 1].name == file.name) {
                fileList.splice(j - 1, 1);
                i--;
                return false;
              }
            }
          }
        }
      }
      let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
      //格式符合后判断大小
      if ("jpg,jpeg,png,gif,jfif,pjpeg,pjp,pdf,doc,docx,xls,xlsx".indexOf(fileType) != -1) {
        let max5M = file.size / 1024 / 1024 < 100;
        if (!max5M) {
          this.$message({
            message: '上传文件大小不得超过100M!',
            type: 'warning'
          });
          fileList = fileList.splice(fileList.length - 1, 1);
        } else {
          //符合条件后进行添加
          this.photographTwo = fileList
        }
      } else {
        this.$message({
          message: '上传文件只能是.jpg,.jpeg,.png,.gif,.jfif,.pjpeg,.pjp,.pdf,.doc,.docx,.xls,.xlsx格式!',
          type: 'warning'
        });
        fileList = fileList.splice(fileList.length - 1, 1);
      }
    },
  }
};
</script>
<style  lang="scss"  scoped>
.upload_lable{
  border-right: 1px solid #dcdfe6;
  padding: 27px 30px;
  background: #fafafa;
  text-align: center;
}
.upload_btn{
  max-height: 106px;
}
.upload_close{
  position: absolute;
  left: 105px;
  z-index:99;
  top:-1px;
  font-size:18px;
  color:red;
}
.upload_close_file{
  position: absolute;
  left: 80px;
  z-index:99;
  top:-1px;
  font-size:18px;
  color:red;
}
.upload_div_image{
  display: inline-block;
  width: 110px;
  height: 95px;
  position: relative;
  float: left;
  margin-left: 5px;
}
.upload_div_file{
  display: inline-block;
  width: 110px;
  height: 95px;
  text-align: center;
  float:left;
  margin: 5px;
  position: relative;
}
.serach_map{
  position: absolute;
  top: 100px;
  left: 25px;
  z-index: 999;
  background: #fff;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0,0,0,.2);
}
</style>