train-apply.js 3.59 KB
"use strict";
const common_vendor = require("../../../common/vendor.js");
const _sfc_main = {
  __name: "train-apply",
  props: {
    trainProjectsList: {},
    examProjectsList: {},
    hotelList: {},
    id: {}
  },
  emits: ["nextFN"],
  setup(__props, { emit }) {
    const props = __props;
    const data = common_vendor.reactive({
      projectIdsArray: []
    });
    const examIdsArry = common_vendor.ref([]);
    const { projectIdsArray } = common_vendor.toRefs(data);
    common_vendor.ref([0]);
    function checkTrain(item) {
      if (item.isNecessary == 1) {
        item.check = true;
      } else {
        item.check = !item.check;
      }
    }
    function upFN() {
      emit("nextFN", 0);
    }
    function nextFN() {
      let falg = true;
      let arr1 = [];
      let arr2 = [];
      props.examProjectsList.forEach((item) => {
        if (item.check) {
          arr1.push(item.id);
        }
      });
      props.trainProjectsList.forEach((item) => {
        if (item.check) {
          arr2.push(item.id);
        }
      });
      let examList = JSON.parse(JSON.stringify(props.examProjectsList));
      let trainList = JSON.parse(JSON.stringify(props.trainProjectsList));
      examList.concat(trainList).forEach((item) => {
        if (item.isNecessary == 1 && item.check == false) {
          falg = false;
        }
      });
      if (falg) {
        examIdsArry.value = arr1;
        projectIdsArray.value = arr2;
        if (props.hotelList.length == 0) {
          let path = `/pages/train/costBreakdown/costBreakdown?id=` + props.id;
          common_vendor.wx$1.navigateTo({
            url: path
          });
        } else {
          emit("nextFN", 2, projectIdsArray.value, examIdsArry.value);
        }
      } else {
        common_vendor.index.showToast({
          title: "请选择必选科目!",
          duration: 2e3,
          icon: "error"
        });
        return false;
      }
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: props.trainProjectsList.length != 0
      }, props.trainProjectsList.length != 0 ? {
        b: common_vendor.f(props.trainProjectsList, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.projectName),
            b: common_vendor.t(item.isNecessary == 1 ? "必选" : "非必选"),
            c: common_vendor.t(item.cost),
            d: item.isNecessary == 1,
            e: item.id,
            f: common_vendor.o(($event) => checkTrain(item), item.id),
            g: item.check,
            h: item.id
          };
        })
      } : {}, {
        c: props.examProjectsList.length != 0
      }, props.examProjectsList.length != 0 ? {
        d: common_vendor.f(props.examProjectsList, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.projectName),
            b: common_vendor.t(item.isNecessary == 1 ? "必选" : "非必选"),
            c: common_vendor.t(item.cost),
            d: item.isNecessary == 1,
            e: item.id,
            f: common_vendor.o(($event) => checkTrain(item), item.id),
            g: item.check,
            h: item.id
          };
        })
      } : {}, {
        e: common_vendor.o(upFN),
        f: common_vendor.o(nextFN),
        g: props.examProjectsList.length == 0 && props.trainProjectsList.length == 0
      }, props.examProjectsList.length == 0 && props.trainProjectsList.length == 0 ? {} : {});
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-108e86d7"], ["__file", "/Users/yangyang/project/j-mini/Venue/components/train/train-apply/train-apply.vue"]]);
wx.createComponent(Component);