train-apply-three.js 8.09 KB
"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_train = require("../../../common/train.js");
require("../../../common/request.js");
require("../../../config.js");
require("../../../common/login.js");
require("../../../common/api.js");
if (!Array) {
  const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
  (_easycom_uni_icons2 + _easycom_uni_datetime_picker2)();
}
const _easycom_uni_icons = () => "../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_uni_datetime_picker = () => "../../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
if (!Math) {
  (_easycom_uni_icons + _easycom_uni_datetime_picker)();
}
const _sfc_main = {
  __name: "train-apply-three",
  props: {
    projectIdsArray: {},
    id: {},
    signId: {},
    examIdsArry: {}
  },
  emits: ["nextFN"],
  setup(__props, { emit }) {
    const props = __props;
    common_vendor.ref([
      {
        id: 1,
        move: null
      }
    ]);
    common_vendor.ref(true);
    common_vendor.ref();
    common_vendor.ref();
    common_vendor.ref();
    common_vendor.ref([]);
    const range = common_vendor.ref();
    const id = common_vendor.ref(props.id);
    const hotelIdsArray = common_vendor.ref();
    common_vendor.ref();
    const remark = common_vendor.ref();
    const flag = common_vendor.ref(true);
    const disabled = common_vendor.ref(false);
    const costID = common_vendor.ref();
    common_vendor.ref();
    const status = common_vendor.ref();
    const signId = common_vendor.ref();
    const data = common_vendor.reactive({
      addForm: {}
    });
    const { addForm } = common_vendor.toRefs(data);
    common_vendor.onShow(() => {
      status.value = 3;
    });
    getList();
    async function getList() {
      addForm.value.id = id.value;
      let res = await common_train.trainParticulars(addForm.value);
      status.value = res.data.signStatus;
      range.value = res.data.hotelList;
      range.value.forEach((item) => {
        let tId = uuid();
        item.move = [
          {
            moveIntoTime: item.moveIntoTime.replace(/-/g, "/"),
            leaveTime: item.leaveTime.replace(/-/g, "/"),
            id: tId,
            hotlId: item.id,
            move: [item.moveIntoTime.replace(/-/g, "/"), item.leaveTime.replace(/-/g, "/")]
          }
        ];
      });
      if (res.data.signId)
        signId.value = res.data.signId;
      console.log(range.value);
    }
    function uuid() {
      var s = [];
      var hexDigits = "0123456789abcdef";
      for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 16), 1);
      }
      s[14] = "4";
      s[19] = hexDigits.substr(s[19] & 3 | 8, 1);
      s[8] = s[13] = s[18] = s[23] = "-";
      var uuid2 = s.join("");
      return uuid2;
    }
    function change(e) {
      hotelIdsArray.value = e.target;
    }
    async function nextFN() {
      await initData();
    }
    function upFN() {
      console.log(111);
      emit("nextFN", 1);
    }
    function radio(e) {
      console.log(e);
      e.target.value == 1 ? flag.value = true : flag.value = false;
      console.log(flag.value);
    }
    async function goRenew() {
      let path = `/pages/train/costBreakdown/costBreakdown?id=` + id.value;
      await common_vendor.wx$1.navigateTo({
        url: path
      });
    }
    function checkedFN(item) {
      item.hotelFlag = !item.hotelFlag;
    }
    function addHot(item) {
      let tId = uuid;
      item.move.push({
        moveIntoTime: item.moveIntoTime.replace(/-/g, "/"),
        leaveTime: item.leaveTime.replace(/-/g, "/"),
        id: tId,
        move: [item.moveIntoTime.replace(/-/g, "/"), item.leaveTime.replace(/-/g, "/")],
        hotlId: item.id
      });
    }
    function delHot(item, val) {
      item.move = item.move.filter((obj) => {
        return obj.id != val.id;
      });
    }
    async function initData() {
      let list = null;
      list = JSON.parse(JSON.stringify(range.value));
      list = list.filter((item) => {
        return item.hotelFlag == true;
      });
      let arr = [];
      list.forEach((item, index) => {
        arr[index] = item;
        arr[index].move = item.move.filter((val) => {
          return val.move.length != 0;
        });
      });
      let arr1 = [];
      arr.forEach((item, index) => {
        item.move.forEach((val) => {
          arr1.push(val);
        });
      });
      let arr2 = [];
      arr1.forEach((item) => {
        item.move = item.move.join();
        arr2.push({
          hotlId: item.hotlId,
          move: item.move
        });
      });
      if (flag.value) {
        if (arr2.length == 0) {
          common_vendor.index.showToast({
            title: "请选择入住酒店!",
            duration: 2e3,
            icon: "error"
          });
          return false;
        }
        addForm.value.hotelIdsArray = arr2;
      } else {
        addForm.value.hotelIdsArray = [];
      }
      addForm.value.projectIdsArray = props.projectIdsArray;
      addForm.value.examIdsArray = props.examIdsArry;
      addForm.value.trainId = id.value;
      addForm.value.remark = remark.value;
      let res = null;
      addForm.value.id = signId.value;
      res = await common_train.trainNext(addForm.value);
      signId.value = res.data;
      costID.value = res.data;
      if (res.code == 200) {
        goRenew();
      }
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: flag.value,
        b: !flag.value,
        c: common_vendor.o(radio),
        d: flag.value
      }, flag.value ? common_vendor.e({
        e: common_vendor.f(range.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.name),
            b: item.hotelFlag,
            c: common_vendor.o(($event) => checkedFN(item), item.id),
            d: "d10e65f1-0-" + i0,
            e: common_vendor.t(item.address),
            f: common_vendor.t(item.houseType),
            g: common_vendor.t(item.spend),
            h: common_vendor.t(item.haveDinner == 1 ? "含早" : "不含早参"),
            i: common_vendor.f(item.move, (val, k1, i1) => {
              return common_vendor.e({
                a: common_vendor.o(($event) => _ctx.maskClick(val), val.id),
                b: "d10e65f1-1-" + i0 + "-" + i1,
                c: common_vendor.o(($event) => val.move = $event, val.id),
                d: common_vendor.p({
                  start: val.moveIntoTime,
                  end: val.leaveTime,
                  type: "daterange",
                  ["return-type"]: "yyyy/MM/dd",
                  modelValue: val.move
                })
              }, item.move.length > 1 ? {
                e: common_vendor.o(($event) => delHot(item, val), val.id),
                f: "d10e65f1-2-" + i0 + "-" + i1,
                g: common_vendor.p({
                  ["custom-prefix"]: "custom-icon",
                  type: "trash",
                  size: "20"
                })
              } : {}, {
                h: val.id
              });
            }),
            j: item.move.length > 1,
            k: common_vendor.o(($event) => addHot(item), item.id),
            l: "d10e65f1-3-" + i0,
            m: item.id
          };
        }),
        f: disabled.value,
        g: common_vendor.p({
          ["custom-prefix"]: "iconfont",
          type: "icon-31dingwei",
          color: "#95A1A6"
        }),
        h: common_vendor.p({
          ["custom-prefix"]: "custom-icon",
          type: "plusempty",
          size: "20"
        }),
        i: common_vendor.o(change),
        j: _ctx.hotelList
      }, _ctx.hotelList ? {
        k: remark.value,
        l: common_vendor.o(($event) => remark.value = $event.detail.value)
      } : {}) : {}, {
        m: common_vendor.o(upFN),
        n: common_vendor.o(nextFN)
      });
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d10e65f1"], ["__file", "/Users/yangyang/project/j-mini/Venue/components/train/train-apply-three/train-apply-three.vue"]]);
wx.createComponent(Component);