routeInfo.vue 10.5 KB
<template>
  <div ref="barEcharts" class="route-info-container">
    <!-- 航线设置规则信息查询条件 -->
    <el-row style="padding: 0 50px">
      <el-col>
        <yl-form
          ref="ruleForm"
          :formConfig="formConfig"
          :queryForm="queryForm"
          :inline="false"
          formWidth="auto"
          @blur="blurEvent"
        >
          <yl-draggable
            :routeList="routeList"
            :dragOptions="dragOptions"
          ></yl-draggable>
        </yl-form>
      </el-col>
    </el-row>
    <!-- 航线设置规则信息 -->
    <el-row>
      <el-col :span="24">
        <el-divider content-position="left">航线维度设置</el-divider>
      </el-col>
      <el-col>
        <route-info
          :routesInfo="routesInfo"
          :cargoType="cargoType"
          :cargoStatus="cargoStatus"
          :puporpux="puporpux"
          :serviceCode="serviceCode"
          :handlingCode="handlingCode"
          :subCategory="subCategory"
          :status="getRouter"
          @collapse="collapseChange"
          @location="changeLocation"
          @destinationSite="changeDestinationSite"
          @cargoType="changeCargoType"
          @cargoStatus="changeCargoStatus"
          @puporpux="changePuporpux"
          @serviceCode="changeServiceCode"
          @handlingCode="changeHandlingCode"
          @subCategory="changeSubCategory"
          @addRlue="addRlue"
        >
        </route-info>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import YlForm from "@/components/YlForm";
import RouteInfo from "./components/routeInfo";
import YlDraggable from "@/components/YlDraggable";
import { formConfig, routeRuleForm } from "./formConfig";
import { removeDuplicates, filterRepeat } from "@/utils";
import {
  allDictData, // 获取全部字典
  findDestinationFltRuleByFlightNo, // 航线维度设置详情
  findByFlightId, // 通过id查询目的航班维度配置详情
  updateOrAddFlight, // 修改
  delFlightId, // 删除航线规则配置
  enableOrDisable, // 是否停用/开启航线规则配置
  batchUpdateOrAddFlight, // 更新航线优先级
  queryRouteByFltNo, // 通过航班号查询航线
} from "@/api/destinationFlight";
import indexMixins from "./mixins";
import { routeData, routeInfo } from "./routeData";
export default {
  components: {
    YlForm,
    RouteInfo,
    YlDraggable,
  },
  mixins: [indexMixins],
  data() {
    return {
      dragOptions: {
        // 航线优先级拖拽配置
        animation: 200,
        group: "description",
        disabled: false, // 是否禁止拖拽
        ghostClass: "ghost",
      },
      formConfig: formConfig, // 表单配置项
      queryForm: {
        // 表单参数
      },
      routeList: [], // 航线
      routesInfo: [], // 航线规则信息
      cargoType: [], // 申报类别
      cargoStatus: [], // 货物类型
      puporpux: [], // 取件扫描号
      serviceCode: [], // Service Code
      handlingCode: [], // Handling Code
      subCategory: [], // Sub Category
    };
  },
  /*
    判断有日期的找到了就走有日期的,如果日期级别的没有找到再去走一次普通级别的接口
  */
  created() {
    this.getAllDictData(); // 获取全部字典
    // 航班配舱维度规则设置查询条件
    let queryCondition = {
      // 航班配舱设置
      flightAllocConfig: {
        queryParmas: () => {
          // 非日期级别
          if (this.$route.query.querySpecifyData == "2") {
            let noDateParmas = {
              flightDate: "",
              flightRoute: "",
              purposeOfFlightNo: this.$route.query.purposeOfFlightNo,
              status: "",
            };
            this.noDateLevelRoute(noDateParmas);
          }
          // 日期级别
          if (this.$route.query.querySpecifyData == "1") {
            let dateParmas = {
              flightDate: this.$route.query.flightDate,
              flightRoute: "",
              flightRouteListStr: "",
              purposeOfFlightNo: this.$route.query.purposeOfFlightNo,
              status: "",
            };
            this.dateLevelRoute(dateParmas);
          }
        },
      },
      // 航班信息维护
      flightInformationMaintenance: {
        queryParmas: () => {
          // White Tail
          if (this.$route.query.flightKindName == "White Tail") {
            let noDateParmas = {
              purposeOfFlightNo: this.$route.query.purposeOfFlightNo,
              flightRouteListStr: this.$route.query.flightRouteListStr,
              status: "",
            };
            this.noDateLevelRoute(noDateParmas);
          }
          // Purple Tail
          if (this.$route.query.flightKindName == "Purple Tail") {
            let dateParmas = {
              purposeOfFlightNo: this.$route.query.purposeOfFlightNo,
              flightDate: this.$route.query.flightDate,
              flightRouteListStr: this.$route.query.flightRouteListStr,
              status: "",
            };
            this.dateLevelRoute(dateParmas);
          }
        },
      },
      // 航班顺位设置
      flightRandConfig: {
        queryParmas: () => {
          // 普通级别
          if (this.$route.query.pageName == "flightRandConfig") {
            let noDateParmas = {
              flightDate: this.$route.query.flightDate,
              flightRoute: "",
              purposeOfFlightNo: this.$route.query.purposeOfFlightNo,
              status: "",
            };
            // 日期级别
            let dateParmas = {
              flightRoute: "",
              flightRouteListStr: "",
              purposeOfFlightNo: this.$route.query.purposeOfFlightNo,
              status: "",
            };
            this.noDateLevelRoute(noDateParmas);
            this.dateLevelRoute(dateParmas);
          }
        },
      },
    };

    // 航班配舱设置
    queryCondition.flightAllocConfig.queryParmas();
    // 航班信息维护
    queryCondition.flightInformationMaintenance.queryParmas();
    // 航班顺位设置
    queryCondition.flightRandConfig.queryParmas();
  },
  mounted() {},
  methods: {
    // 普通级别的
    noDateLevelRoute(parmas) {
      findDestinationFltRuleByFlightNo(parmas)
        .then((res) => {
          const { code, data, msg } = res;
          if (code != 200) {
            this.msgError(msg);
            return;
          }
          let routeList = data.routeList; // 航班航线基本信息
          // 普通级别航班航线维度规则详情
          const dataList = removeDuplicates(data.list, {
            duplicate: "flightRoute", // 去重字段
            sort: false, // 是否要排序
            sortType: "Number", // 排序类型
            sortAttr: "routePriority", // 排序字段
          });
          // 【日期规则】
          const dateFlightRoute = routeList.map((item1) => {
            const item2 = dataList.unique.find((item2) => {
              if (item2.flightRoute === item1.route) {
                item2.config = true;
                return item2;
              }
            }); // 返回当前相等的一条数据
            if (item2) {
              // 有数据的合并对象,
              return { ...item1, ...item2 };
            } else {
              // 没有数据的去普通航线里查找
              const item = dataList.unique.find((item) => {
                if (item.flightRoute === item1.route) {
                  item.config = true;
                  return item;
                }
              });
              if (item) {
                return { ...item1, ...item }; // 有数据的合并对象,
              } else {
                item1.config = false;
                return item1; // 没有的返回当前的
              }
            }
          });
          // 处理属性
          dateFlightRoute.map((item) => {
            if (item.config) {
              this.hasOwnProperty(item, "typeOfGoods");
              this.hasOwnProperty(item, "puporpuxCode");
              this.hasOwnProperty(item, "serviceCode");
              this.hasOwnProperty(item, "handlingCode");
              this.hasOwnProperty(item, "subCategory");
              this.setattrVal(item); // 设置属性值
            }
          });
          this.routesInfo = dateFlightRoute;
        })
        .catch(() => {});
    },
    // 日期级别的
    dateLevelRoute(parmas) {
      findDestinationFltRuleByFlightNo(parmas).then((res) => {
        const { code, data, msg } = res;
        if (code != 200) {
          this.msgError(msg);
          return;
        }
        let routeList = data.routeList; // 航班航线基本信息
        this.routeList = data.routeList;
        // 日期级别航班航线维度规则详情
        const dataList = removeDuplicates(data.list, {
          duplicate: "flightRoute", // 去重字段
          sort: false, // 是否要排序
          sortType: "Number", // 排序类型
          sortAttr: "routePriority", // 排序字段
        });
        let config = false; // 有缺省的航线配置
        const dateFlightRoute = routeList.map((item1) => {
          const item2 = dataList.unique.find((item2) => {
            if (item2.flightRoute === item1.route) {
              config = item2.config = true;
              if (this.$route.query.pageName == "flightAllocConfig") {
                item2.remark = true;
              } else {
                item2.remark = false;
              }
              return item2;
            }
          }); // 返回当前相等的一条数据
          if (item2) {
            return { ...item1, ...item2 };
          } else {
            config = item1.config = false;
            return item1; // 没有的返回当前的
          }
        });
        // 处理属性
        dateFlightRoute.map((item) => {
          if (item.config) {
            this.hasOwnProperty(item, "typeOfGoods");
            this.hasOwnProperty(item, "puporpuxCode");
            this.hasOwnProperty(item, "serviceCode");
            this.hasOwnProperty(item, "handlingCode");
            this.hasOwnProperty(item, "subCategory");
            this.setattrVal(item); // 设置属性值
          }
        });
        this.routesInfo = dateFlightRoute;
      });
    },
    // 新增规则
    addRlue(index) {
      // 如果当前航班号的航线下没有数据给
      this.setattrVal(routeRuleForm);
      const mergeObj = {
        ...this.routesInfo[index],
        ...routeRuleForm,
      };
      this.$set(this.routesInfo, index, mergeObj); // 给新增规则赋上默认数据
      console.log("新增规则:", this.routesInfo);
    },
  },
};
</script>
<style lang="scss" scoped>
.route-info-container {
  padding: 20px;
}
</style>