index.vue 32.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 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928
<template>
  <div>
    <el-form class="form-header" :model="queryParams" ref="queryForm" label-position="right" label-width="auto"
      size="small">
      <el-row>
        <el-col :span="6">
          <el-form-item label="航班日期从" prop="fltDateStart">
            <el-date-picker class="formItem" value-format="yyyy-MM-dd" v-model="queryParams.fltDateStart" type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="到" prop="fltDateEnd">
            <el-date-picker class="formItem" value-format="yyyy-MM-dd" v-model="queryParams.fltDateEnd" type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="航班号" prop="fltNo">
            <el-input class="formItem" v-model="queryParams.fltNo" placeholder="请输入航班号" clearable />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="航班类型" prop="typeId">
            <el-select class="formItem" v-model="queryParams.typeId" placeholder="请选择航班类型" clearable>
              <el-option v-for="dict in selectOption.flightTypelist" :key="dict.id" :label="dict.chineseName"
                :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="航班状态" prop="statusId">
            <el-select class="formItem" v-model="queryParams.statusId" placeholder="请选择航班状态" clearable>
              <el-option v-for="dict in selectOption.flightStatuslist" :key="dict.id" :label="dict.chineseName"
                :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="航班种类" prop="flightKindId">
            <el-select class="formItem" v-model="queryParams.flightKindId" placeholder="请选择航班种类" clearable>
              <el-option v-for="dict in selectOption.flightKindlist" :key="dict.id" :label="dict.chineseName"
                :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['base:flightInfo:add']">
        新增</el-button>
      <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="ids.length == 0"
        @click="handleFlightStatus('flightStatus10')" v-hasPermi="['base:flightInfo:open']">自动配舱开启</el-button>
      <el-button type="primary" icon="el-icon-circle-close" size="mini" :disabled="ids.length == 0"
        @click="handleFlightStatus('flightStatus80')" v-hasPermi="['base:flightInfo:close']">自动配舱关闭</el-button>
      <el-button type="primary" icon="el-icon-circle-check" size="mini" :disabled="ids.length == 0"
        @click="autoPushBatch('open')" v-hasPermi="['base:flightInfo:autoPushOpen']">自动推送开启</el-button>
      <el-button type="primary" icon="el-icon-circle-close" size="mini" :disabled="ids.length == 0"
        @click="autoPushBatch('close')" v-hasPermi="['base:flightInfo:autoPushClose']">自动推送关闭</el-button>
      <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="ids.length == 0" @click="handleDelete"
        v-hasPermi="['base:flightInfo:delete']">删除
      </el-button>
    </el-form>
    <Tables ref="flightInfoTable" ductName="FlightInformation" :data="findAllFltDatList" :headerData="tableHeader"
      :order="true" :selection="true" :totalCount="total" :loading="loading" :limitSize="queryParams.limitSize"
      :page="queryParams.pageNum" :shiftKey="shiftKey" :height="tableHeight" :pageSizes="[20, 30, 40, 50, 100]"
      @tableSelect="tableSelect" @tableSelectAll="tableSelectAll" @currentChange="currentChange"
      @sortChange="sortChange" @sizeChange="sizeChange">
      <template slot="optionColumn">
        <el-table-column v-if="findAllFltDatList.length > 0" label="操作" align="center"
          class-name="small-padding fixed-width" fixed="right">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
              v-hasPermi="['base:flightInfo:update']">修改</el-button>
          </template>
        </el-table-column>
      </template>
    </Tables>
    <!-- 添加或修改对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="60%" :close-on-click-modal="false" :append-to-body="true"
      :show-close="false">
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="auto" size="small">
        <el-row>
          <el-col :span="12">
            <el-form-item label="航班号" prop="fltNo">
              <el-input class="wid80" @blur="blurfltNo" :disabled="formdisabled.fltNo" v-model="form.fltNo"
                placeholder="请输入航班号" maxlength="10" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="航班日期" prop="fltDate">
              <el-date-picker class="wid80" :disabled="formdisabled.fltDate" clearable size="small"
                v-model="form.fltDate" type="date" value-format="yyyy-MM-dd" placeholder="选择航班日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="Pre-MDE CutOff时间" prop="cutOffTime">
              <el-select class="wid80" v-model="form.cutOffTime" clearable placeholder="选择时间(输入查找选项)" type="string"
                filterable>
                <el-option v-for="item in selectOption.cutOffTime" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="航班路线" prop="route">
              <el-input class="wid80" v-model="form.route" placeholder="请输入航班路线(XXX-XXX字母大写)" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="航班种类" prop="kindId">
              <el-select class="wid80" v-model="form.kindId" placeholder="请选择航班种类">
                <el-option v-for="item in selectOption.flightKindlist" :key="item.id" :label="item.chineseName"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="航班类型" prop="typeId">
              <el-select class="wid80" v-model="form.typeId" placeholder="请选择航班类型">
                <el-option v-for="item in selectOption.flightTypelist" :key="item.id" :label="item.chineseName"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="航班状态" prop="statusId">
              <el-select class="wid80" :disabled="true" v-model="form.statusId" placeholder="请选择航班状态">
                <el-option v-for="item in selectOption.flightStatuslist" :key="item.id" :label="item.chineseName"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原始重量(KG)" prop="originalWeight">
              <el-input-number class="wid80" @change="LowHighAvailable" :precision="0" placeholder="请输入原始重量(KG)"
                v-model="form.originalWeight"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="额外增重百分比" prop="extraWeightPercent">
              <el-input-number class="wid80" @change="LowHighAvailable" :precision="0" placeholder="请输入额外增重百分比"
                v-model="form.extraWeightPercent"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否开启高低价" prop="highLowPriceFlg">
              <el-switch class="wid80" @change="LowHighAvailable" v-model="form.highLowPriceFlg" :active-value="1"
                :inactive-value="0" active-color="#13ce66">
              </el-switch>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否预审" prop="isNeedRequired">
              <el-switch class="wid80" :disabled="true" v-model="form.isNeedRequired" :active-value="1"
                :inactive-value="0" active-color="#13ce66">
              </el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高价百分比" prop="highPriceWeightPercent">
              <el-input-number class="wid80" :disabled="ishighPriceWeightPercent" @change="LowHighAvailable"
                placeholder="请输入高价百分比" v-model="form.highPriceWeightPercent"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="低价百分比" prop="lowPriceWeightPercent">
              <el-input-number class="wid80" :disabled="true" placeholder="请输入低价百分比"
                v-model="form.lowPriceWeightPercent"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高价可配重量" prop="highAvailableWeight">
              <el-input-number class="wid80" :disabled="true" placeholder="请输入高价可配重量" v-model="form.highAvailableWeight"
                :precision="2"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="低价可配重量" prop="lowAvailableWeight">
              <el-input-number class="wid80" :disabled="true" placeholder="请输入低价可配重量" v-model="form.lowAvailableWeight"
                :precision="2"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高价已配重量" prop="highAllocatedWeight">
              <el-input-number class="wid80" :disabled="true" placeholder="请输入高价已配重量" v-model="form.highAllocatedWeight"
                :precision="2"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="低价已配重量" prop="lowAllocatedWeight">
              <el-input-number class="wid80" :disabled="true" placeholder="请输入低价已配重量" v-model="form.lowAllocatedWeight"
                :precision="2"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="已配总重量" prop="alloctedWeight">
              <el-input-number class="wid80" :disabled="true" placeholder="请输入已配总重量" v-model="form.alloctedWeight"
                :precision="2"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="未删除成功航班" width="40%" center :visible.sync="dialogTableVisible" :close-on-click-modal="false"
      :append-to-body="true" :show-close="false">
      <el-table :data="gridData">
        <el-table-column property="fltNo" label="航班号"></el-table-column>
        <el-table-column property="fltDate" label="航班日期"></el-table-column>
        <el-table-column property="alloctedWeight" label="已配重量"></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import {
  delFlight,
  findFltConditionDataApi,
  findAllFltDataApi,
  findFltById,
  saveOrUpdate,
  findFltCommonConf,
  updateStatusBatch,
  updateAutoPushBatch,
} from "@/api/findAllFltData";

export default {
  name: "FlightInformationMaintenance",
  data() {
    return {
      //查询参数
      queryParams: {
        limitStart: 0, //当前条数【代表第几条数据 +1开始】
        pageNum: 1,
        limitSize: 20, //一页显示多少条数据
        fltDateStart: undefined, //航班日期开始
        fltDateEnd: undefined, //航班日期结束
        typeId: undefined, //航班类型
        statusId: undefined, //航班状态
        flightKindId: undefined, //航班种类
        fltNo: undefined, //航班号,要大写
      },
      //表单参数
      form: {},
      //表单校验
      rules: {
        fltNo: [
          {
            required: true,
            message: "ACCS原航班号不能为空",
            trigger: "blur",
          },
        ],
        fltDate: [
          {
            required: true,
            message: "航班日期不能为空",
            trigger: "blur",
          },
        ],
        kindId: [
          {
            required: true,
            message: "航班种类不能为空",
            trigger: "change",
          },
        ],
        originalWeight: [
          {
            required: true,
            message: "原始重量(KG)不能为空",
            trigger: "blur",
          },
        ],
        // route: [
        //   {
        //     required: true,
        //     message: "航班线路不能为空",
        //     trigger: "blur",
        //   },
        //   {
        //     pattern: /^([A-Z]{3,4})(\-[A-Z]{3,4})+$/,
        //     message: "请输入正确得航班线路"
        //   }
        // ]
      },
      //原航班规则数据
      findAllFltDatList: [],
      //表头
      tableHeader: this.tableHeaders['FlightInformation'],
      //删除失败数据
      gridData: [],
      //form属性禁用状态
      formdisabled: {
        //航班号
        fltNo: false,
        //航班日期
        fltDate: false,
        //航班路线
        route: false,
        //航班种类
        kindId: false,
        //航班类型
        typeId: false,
        //原始重量
        originalWeight: false,
      },
      //下拉框数据
      selectOption: {
        //航班种类
        flightKindlist: [],
        //航班状态
        flightStatuslist: [],
        //航班类型
        flightTypelist: [],
        //cutOffTime数据
        cutOffTime: [
          "00:00:00",
          "00:30:00",
          "01:00:00",
          "01:30:00",
          "02:00:00",
          "02:30:00",
          "03:00:00",
          "03:30:00",
          "04:00:00",
          "04:30:00",
          "05:00:00",
          "05:30:00",
          "06:00:00",
          "06:30:00",
          "07:00:00",
          "07:30:00",
          "08:00:00",
          "08:30:00",
          "09:00:00",
          "09:30:00",
          "10:00:00",
          "10:30:00",
          "11:00:00",
          "11:30:00",
          "12:00:00",
          "12:30:00",
          "13:00:00",
          "13:30:00",
          "14:00:00",
          "14:30:00",
          "15:00:00",
          "15:30:00",
          "16:00:00",
          "16:30:00",
          "17:00:00",
          "17:30:00",
          "18:00:00",
          "18:30:00",
          "19:00:00",
          "19:30:00",
          "20:00:00",
          "20:30:00",
          "21:00:00",
          "21:30:00",
          "22:00:00",
          "22:30:00",
          "23:00:00",
          "23:30:00",
        ],
      },
      //选中数组
      ids: [],
      //目的航班数据
      sourceFlightAndFlightDate: [],
      //高价百分比是否打开
      ishighPriceWeightPercent: true,
      //遮罩层
      loading: false,
      //遮罩层
      loadingFlightDate: false,
      //删除失败弹框
      dialogTableVisible: false,
      //弹出层标题
      title: "",
      //总条数
      total: 0,
      //表格高度
      tableHeight: null,
      //新增修改查看规则弹出层
      open: false,
      //是否显示查看目的航班弹出层
      openFlightDate: false,
      //shift键状态
      shiftKey: false,
    };
  },
  created() {
    //查询条件数据源
    this.queryParams.fltDateStart = this.nowDate()
    if (this.$store.state.tagsView.cachedViews.length == 0) {
      this.findFltConditionData();
      this.findAllFltData();
    }
  },
  activated() {
    this.findFltConditionData();
    this.findAllFltData();
  },
  deactivated() {
    this.findAllFltDatList = [];
  },
  mounted() {
    window.addEventListener("keydown", (code) => {
      if (code.keyCode === 16 && code.shiftKey) {
        this.shiftKey = true;
      }
    });
    window.addEventListener("keyup", (code) => {
      if (code.keyCode === 16) {
        this.shiftKey = false;
      }
    });
    this.tableHeight =
      window.innerHeight - this.$refs.queryForm.$el.offsetHeight - 120;
  },
  methods: {
    //输入航班号后
    blurfltNo() {
      if (
        this.form.fltNo != null &&
        this.form.fltNo != undefined &&
        this.form.fltNo != ""
      ) {
        this.form.fltNo = this.form.fltNo.toUpperCase();
        findFltCommonConf(this.form).then((response) => {
          if (response.code == 200) {
            //额外增重百分比:根据已存在的相同航班号对应的最新值进行设置,如果无相同航班号,按照默认设置为0,不可编辑
            if (
              response.data != null &&
              response.data.extraWeightPercent != null &&
              response.data.extraWeightPercent != undefined
            ) {
              this.$set(
                this.form,
                "extraWeightPercent",
                response.data.extraWeightPercent
              );
              // this.form.extraWeightPercent=response.data.extraWeightPercent;
            } else {
              this.$set(this.form, "extraWeightPercent", 0);
              //this.form.extraWeightPercent=response.data.extraWeightPercent=0;
            }
            //是否开启高低价:根据已存在的相同航班号对应的最新值进行设置,如果无相同航班号,按照默认设置‘是否开启高低价’ 为是,不可编辑
            if (
              response.data != null &&
              response.data.highLowPriceFlg != null &&
              response.data.highLowPriceFlg != undefined
            ) {
              this.form.highLowPriceFlg = response.data.highLowPriceFlg;
            } else {
              this.$set(this.form, "highLowPriceFlg", 1);
              //this.form.highLowPriceFlg = true;
            }
            //是否预审:根据已存在的相同航班号对应的最新值进行设置,如果无相同航班号,按照默认设置‘是否预审’ 为否,不可编辑;
            if (
              response.data != null &&
              response.data.isNeedRequired != null &&
              response.data.isNeedRequired != undefined
            ) {
              this.form.isNeedRequired = response.data.isNeedRequired;
            } else {
              this.form.isNeedRequired = 0;
            }
            //高/低价百分比:根据已存在的相同航班号对应的最新值进行设置,如果无相同航班号,按照默认设置‘高价百分比’60%,‘低价百分比’40%,不可编辑
            if (
              response.data != null &&
              response.data.highPriceWeightPercent != null &&
              response.data.highPriceWeightPercent != undefined
            ) {
              this.form.highPriceWeightPercent =
                response.data.highPriceWeightPercent;
            } else {
              this.form.highPriceWeightPercent = 60;
            }
            if (
              response.data != null &&
              response.data.lowPriceWeightPercent != null &&
              response.data.lowPriceWeightPercent != undefined
            ) {
              this.form.lowPriceWeightPercent =
                response.data.lowPriceWeightPercent;
            } else {
              this.form.lowPriceWeightPercent = 40;
            }
            this.LowHighAvailable();
          } else {
            this.msgError(response.msg);
          }
        });
      }
    },
    //查询条件数据源
    findFltConditionData() {
      findFltConditionDataApi().then((response) => {
        if (response.code == 200) {
          //航班种类
          this.selectOption.flightKindlist = response.data.flightKind;
          //航班类型
          this.selectOption.flightTypelist = response.data.flightType;
          //航班状态
          this.selectOption.flightStatuslist = response.data.flightStatus;
        } else {
          this.msgError(response.msg);
        }
      });
    },
    /** 航班信息维护查询*/
    findAllFltData() {
      this.ids = [];
      this.loading = true;
      if (this.queryParams.pageNum > 1) {
        this.queryParams.limitStart =
          (this.queryParams.pageNum - 1) * this.queryParams.limitSize;
      } else {
        this.queryParams.limitStart = 0;
      }
      if (
        this.queryParams.fltNo != null &&
        this.queryParams.fltNo != undefined &&
        this.queryParams.fltNo != ""
      ) {
        this.queryParams.fltNo = this.queryParams.fltNo.toUpperCase();
      }
      findAllFltDataApi(this.queryParams).then((response) => {
        this.loading = false;
        if (response.code == 200) {
          this.findAllFltDatList = response.data.list;
          this.total = response.data.totalCount;
        } else {
          this.msgError(response.msg);
        }
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.findFltConditionData();
      this.open = true;
      this.title = "添加航班信息";
      this.form.id = null;
      this.form.statusId = this.selectOption.flightStatuslist[0].id;
      this.form.alloctedWeight = 0; //已配重量
      this.form.lowAllocatedWeight = 0; //低价已配重量
      this.form.highAllocatedWeight = 0; //高价已配重量
      //航班号
      this.formdisabled.fltNo = false;
      //航班日期
      this.formdisabled.fltDate = false;
      //航班路线
      this.formdisabled.route = false;
      //航班种类
      this.formdisabled.kindId = false;
      //航班类型
      this.formdisabled.typeId = false;
      //原始重量
      this.formdisabled.originalWeight = false;
    },
    //计算高低价可配
    LowHighAvailable() {
      //判断是否开启高低价
      if (this.form.highLowPriceFlg) {
        this.ishighPriceWeightPercent = false;
        let Weight = 0;
        //计算实际重量
        if (
          this.form.highPriceWeightPercent > 0 ||
          this.form.lowPriceWeightPercent > 0
        ) {
          Weight = this.Weightall();
        }
        //高价可配
        if (this.form.highPriceWeightPercent >= 0) {
          this.$set(
            this.form,
            "highAvailableWeight",
            (Weight - this.form.alloctedWeight) *
            (this.form.highPriceWeightPercent / 100)
          );
          this.$set(
            this.form,
            "lowPriceWeightPercent",
            100 - this.form.highPriceWeightPercent
          );
          // this.form.HighAvailableWeight = Weightall * (this.form.highPriceWeightPercent / 100)
        } else if (
          this.title == "修改航班信息" &&
          this.form.highPriceWeightPercent > 0
        ) {
          if (this.form.highAvailableWeight) {
            this.$set(
              this.form,
              "highAvailableWeight",
              this.form.highAvailableWeight
            );
          } else {
            this.$set(
              this.form,
              "highAvailableWeight",
              (Weight - this.form.alloctedWeight) *
              (this.form.highPriceWeightPercent / 100)
            );
          }
        } else {
          this.$set(this.form, "highAvailableWeight", 0);
          // this.form.HighAvailableWeight = 0;
        }
        //低价可配
        if (this.form.lowPriceWeightPercent > 0) {
          this.$set(
            this.form,
            "lowAvailableWeight",
            Weight - this.form.alloctedWeight - this.form.highAvailableWeight
          );
          //this.form.lowAvailableWeight = Weightall - this.form.HighAvailableWeight;
        } else if (
          this.title == "修改航班信息" &&
          this.form.lowPriceWeightPercent > 0
        ) {
          if (this.form.lowAvailableWeight) {
            this.$set(
              this.form,
              "lowAvailableWeight",
              this.form.lowAvailableWeight
            );
          } else {
            this.$set(
              this.form,
              "lowAvailableWeight",
              Weight - this.form.alloctedWeight - this.form.highAvailableWeight
            );
          }
        } else {
          this.$set(this.form, "lowAvailableWeight", 0);
          // this.form.lowAvailableWeight = 0;
        }
      } else {
        this.ishighPriceWeightPercent = true;
      }
    },
    //计算实际重量
    Weightall() {
      let Weight = 0;
      if (this.form.extraWeightPercent > 0) {
        Weight = this.form.originalWeight * (this.form.extraWeightPercent / 100) + this.form.originalWeight;
      } else {
        Weight = this.form.originalWeight;
      }
      return Weight;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.findFltConditionData();
      this.open = true;
      this.title = "修改航班信息";
      //航班号
      this.formdisabled.fltNo = true;
      //航班日期
      this.formdisabled.fltDate = true;
      //根据ID查item
      findFltById(row).then((response) => {
        if (response.code == 200) {
          this.form = response.data;
          //是否开启高低价
          // this.form.highLowPriceFlg = this.form.highLowPriceFlg === 1 ? true : false;
          //是否预审
          // this.form.isNeedRequired = this.form.isNeedRequired === 1 ? true : false;
          // 计算高低价可配
          // this.LowHighAvailable();
        } else {
          this.msgError(response.msg);
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      let fIds = [];
      this.ids.forEach(item => {
        fIds.push(item.id)
      })
      this.$confirm("是否确认删除所选数据?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return delFlight(fIds);
        })
        .then((response) => {
          this.findAllFltData();
          if (response.data.length > 0) {
            this.gridData = response.data;
            this.$confirm(response.msg, "提示", {
              confirmButtonText: "查看删除失败航班信息",
              cancelButtonText: "取消",
              type: "warning",
              center: true,
            })
              .then(() => {
                this.dialogTableVisible = true;
              })
              .catch(() => { });
          } else {
            this.msgSuccess(response.msg);
          }
        })
        .catch(() => { });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          let formdata = JSON.parse(JSON.stringify(this.form));
          //高价百分比和低价百分比和不可以大于100
          if (
            this.form.highLowPriceFlg &&
            (formdata.highPriceWeightPercent > 100 ||
              formdata.highPriceWeightPercent < 0)
          ) {
            this.$message.warning("请正确填写高低价百分比");
            return;
          }
          //已删除的无法修改
          //拿到已删除的id
          let statusId = 0;
          this.selectOption.flightStatuslist.map((item) => {
            //  this.unitList 是你 select option遍历的集合 e 是选中的id
            if (item.chineseName === "已删除") {
              statusId = item.id;
              return;
            }
          });
          if (statusId === formdata.statusId) {
            this.$message.warning("已删除的航班无法修改");
            return;
          }
          //是否开启高低价
          // formdata.highLowPriceFlg = formdata.highLowPriceFlg ? 1 : 0;
          //是否预审
          // formdata.isNeedRequired = formdata.isNeedRequired ? 1 : 0;
          //总重量更新
          // formdata.totalWeight = this.Weightall()
          //处理数据
          saveOrUpdate(formdata).then((response) => {
            if (response.code === 200) {
              this.msgSuccess("保存成功");
              this.open = false;
              this.findAllFltData();
            } else {
              this.msgError(response.msg);
            }
          });
        }
      });
    },
    //表单重置
    reset() {
      this.form = {};
      this.resetForm("form");
    },
    //取消按钮
    cancel() {
      this.open = false;
      this.findAllFltData();
      this.findFltConditionData();
      this.reset();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.start = 0;
      this.findAllFltData();
    },
    //批量开启/关闭航班
    handleFlightStatus(status) {
      let handle = status == "flightStatus80" ? "关闭" : "开启";
      let data = {
        updateIds: [],
      };
      this.ids.map(item => {
        data.status = status;
        if (status === 'flightStatus80') {
          if (item.statusName === '已开启') {
            data.updateIds.push(item.id)
          }
        } else {
          if (item.statusName === '已关闭') {
            data.updateIds.push(item.id)
          }
        }
      })
      if (data.updateIds.length > 0) {
        updateStatusBatch(data).then((response) => {
          if (response.code === 200) {
            this.msgSuccess(handle + "成功");
            this.findAllFltData();
          } else {
            this.msgError(response.msg);
          }
        });
      }
    },
    //自动推送开关
    autoPushBatch(status) {
      let msg = status == "open" ? "开启" : "关闭";
      let data = {
        updateIds: [],
      };
      this.ids.map((item) => {
        if (status === "open") {
          data.status = "1";
          if (item.pushDateSwitch != "1") {
            data.updateIds.push(item.id);
          }
        } else if (status === "close") {
          data.status = "2";
          if (item.pushDateSwitch != "2") {
            data.updateIds.push(item.id);
          }
        }
      });
      if (data.updateIds.length > 0) {
        updateAutoPushBatch(data)
          .then((res) => {
            if (res.code === 200) {
              this.msgSuccess(`自动推送${msg}成功`);
              this.findAllFltData();
            } else {
              this.msgError(res.msg);
            }
          })
          .catch(err => {
            this.msgError(err);
          });
      } else {
        this.msgSuccess(`自动推送${msg}成功`);
        this.findAllFltData();
      }
    },
    //多选框选中数据
    tableSelect(val) {
      this.ids = val.selection;
    },
    //全选
    tableSelectAll(val) {
      this.ids = val;
    },
    //分页
    currentChange(val) {
      this.queryParams.pageNum = val.page;
      this.findAllFltData();
    },
    //排序
    sortChange(val) {
      console.log(val);
    },
    //每页长度
    sizeChange(val) {
      this.queryParams.limitSize = val;
      this.findAllFltData();
    },
    setClose() {
      this.tableHeader = this.tableHeaders['FlightInformation']
    },
  },
  computed: {
    route: {
      get: function () {
        return this.form.route;
      },
      set: function (val) {
        this.form.route = this.upCase(val);
      },
    }
  }
};
</script>

<style>
.el-table--striped .el-table__body tr.el-table__row--striped.current-row td,
.el-table__body tr.current-row>td {
  background-color: #a0cfff;
}

.el-table--striped .el-table__body tr.hover-row.el-table__row--striped>td,
.el-table__body tr.hover-row>td {
  background-color: #d9ecff !important;
}
</style>