"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
  const _easycom_up_th2 = common_vendor.resolveComponent("up-th");
  const _easycom_up_tr2 = common_vendor.resolveComponent("up-tr");
  const _easycom_up_table2 = common_vendor.resolveComponent("up-table");
  (_easycom_up_th2 + _easycom_up_tr2 + _easycom_up_table2)();
}
const _easycom_up_th = () => "../../node-modules/uview-plus/components/u-th/u-th.js";
const _easycom_up_tr = () => "../../node-modules/uview-plus/components/u-tr/u-tr.js";
const _easycom_up_table = () => "../../node-modules/uview-plus/components/u-table/u-table.js";
if (!Math) {
  (_easycom_up_th + SsSelect + Td + _easycom_up_tr + SsInput + SsOnoffButton + _easycom_up_table + Form + SeatLayout + SsBottom)();
}
const Form = () => "../../components/Form/index.js";
const Td = () => "../../components/Td/index.js";
const SsInput = () => "../../components/SsInput/index.js";
const SsSelect = () => "../../components/SsSelect/index.js";
const SsOnoffButton = () => "../../components/SsOnoffButton/index.js";
const SeatLayout = () => "./components/SeatLayout.js";
const SsBottom = () => "../../components/SsBottom/index.js";
const _sfc_main = {
  __name: "kqjl_bzrDm",
  setup(__props) {
    const formData = common_vendor.ref({
      bj: "1",
      rq: "2025年6月31日 星期五",
      jc: "1"
      // 默认选中上午
    });
    const attendanceMode = common_vendor.ref("overview");
    const studentList = common_vendor.ref([]);
    const seatLayout = common_vendor.ref({ rows: 5, cols: 10 });
    const showPullIndicator = common_vendor.ref(false);
    const pullStartY = common_vendor.ref(0);
    const pullDistance = common_vendor.ref(0);
    const displayText = common_vendor.computed(() => {
      var _a;
      const bjText = ((_a = bjOption.value.find((item) => item.v === formData.value.bj)) == null ? void 0 : _a.n) || "未选择班级";
      const jcText = formData.value.jc === "1" ? "上午" : formData.value.jc === "2" ? "下午" : "晚上";
      return `${bjText}  ${formData.value.rq}  ${jcText}`;
    });
    const fieldConfigs = {
      bj: {
        rules: [{ required: true, message: "班级不能为空" }]
      },
      rq: {
        rules: [{ required: true, message: "日期不能为空" }]
      },
      jc: {
        rules: [{ required: true, message: "请选择节次" }]
      }
    };
    const formRef = common_vendor.ref(null);
    const bjOption = common_vendor.ref([
      { n: "一年级一班", v: "1" },
      { n: "一年级二班", v: "2" }
      // TODO: 调用 getClassList() 接口获取真实班级数据
    ]);
    const bjLoading = common_vendor.ref(false);
    const onXcTypeChange = (value, option) => {
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:209", "班级选择变化:", value, option);
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:210", "当前formData.bj:", formData.value.bj);
      loadStudentData();
    };
    const loadStudentData = async () => {
      try {
        const mockStudents = [];
        for (let row = 1; row <= 5; row++) {
          for (let col = 1; col <= 10; col++) {
            const studentId = `${row}${col.toString().padStart(2, "0")}`;
            mockStudents.push({
              id: studentId,
              name: `学生${studentId}`,
              code: studentId,
              avatar: "/static/logo.png",
              // 默认头像
              row,
              // 座位行号
              col,
              // 座位列号
              status: 81
              // 考勤状态：81-出勤, 1-旷课, 11-迟到, 21-早退, 0-请假
            });
          }
        }
        studentList.value = mockStudents;
        seatLayout.value = { rows: 5, cols: 10 };
        common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:253", "学生数据加载完成:", studentList.value.length);
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/kqjl/kqjl_bzrDm.vue:255", "加载学生数据失败:", error);
        common_vendor.index.showToast({
          title: "加载学生数据失败",
          icon: "none"
        });
      }
    };
    const handleModeChange = (newMode) => {
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:269", "模式切换:", attendanceMode.value, "->", newMode);
      if (newMode === "overview") {
        attendanceMode.value = "overview-simple";
      } else {
        attendanceMode.value = newMode;
      }
    };
    const handleStatusChange = (statusData) => {
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:290", "学生状态变化:", statusData);
      const student = studentList.value.find((s) => s.id === statusData.studentId);
      if (student) {
        student.status = statusData.newStatus;
      }
    };
    const handleStudentClick = (student) => {
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:314", "点击学生:", student);
    };
    const handlePageTouchStart = (e) => {
      if (attendanceMode.value !== "overview-simple")
        return;
      if (!e.touches || !e.touches[0])
        return;
      pullStartY.value = e.touches[0].clientY;
      pullDistance.value = 0;
    };
    const handlePageTouchMove = (e) => {
      if (attendanceMode.value !== "overview-simple")
        return;
      if (!e.touches || !e.touches[0])
        return;
      const currentY = e.touches[0].clientY;
      pullDistance.value = currentY - pullStartY.value;
      if (pullDistance.value > 50) {
        showPullIndicator.value = true;
      } else {
        showPullIndicator.value = false;
      }
    };
    const handlePageTouchEnd = () => {
      if (attendanceMode.value !== "overview-simple")
        return;
      if (pullDistance.value > 100) {
        attendanceMode.value = "overview";
      }
      showPullIndicator.value = false;
      pullDistance.value = 0;
    };
    const bottomButtons = [
      { text: "取消", action: "back" },
      { text: "保存", action: "save" }
    ];
    const handleBottomAction = (data) => {
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:391", "底部按钮操作:", data);
      switch (data.action) {
        case "cancel":
          common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:396", "取消操作");
          break;
        case "back":
          common_vendor.index.navigateBack();
          break;
        case "save":
          handleSave();
          break;
      }
    };
    const handleSave = async () => {
      common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:415", "保存学生考勤数据");
      try {
        const attendanceData = studentList.value.map((student) => ({
          id: student.id,
          name: student.name,
          code: student.code,
          row: student.row,
          col: student.col,
          status: student.status,
          statusText: getStatusText(student.status)
        }));
        common_vendor.index.__f__("log", "at pages/kqjl/kqjl_bzrDm.vue:429", "所有学生考勤状态:", attendanceData);
        common_vendor.index.showToast({
          title: "保存成功",
          icon: "success"
        });
      } catch (error) {
        common_vendor.index.__f__("error", "at pages/kqjl/kqjl_bzrDm.vue:448", "保存考勤数据失败:", error);
        common_vendor.index.showToast({
          title: "保存失败",
          icon: "none"
        });
      }
    };
    const getStatusText = (status) => {
      switch (status) {
        case 81:
          return "出勤";
        case 1:
          return "旷课";
        case 11:
          return "迟到";
        case 21:
          return "早退";
        case 0:
          return "请假";
        default:
          return "未知";
      }
    };
    loadStudentData();
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: attendanceMode.value === "overview"
      }, attendanceMode.value === "overview" ? {
        b: common_vendor.o(onXcTypeChange),
        c: common_vendor.o(($event) => formData.value.bj = $event),
        d: common_vendor.p({
          options: bjOption.value,
          loading: bjLoading.value,
          placeholder: "请选择班级",
          modelValue: formData.value.bj
        }),
        e: common_vendor.p({
          field: "bj"
        }),
        f: common_vendor.o(($event) => formData.value.rq = $event),
        g: common_vendor.p({
          placeholder: "请输入日期",
          modelValue: formData.value.rq
        }),
        h: common_vendor.p({
          field: "rq"
        }),
        i: common_vendor.o(($event) => formData.value.jc = $event),
        j: common_vendor.p({
          name: "jc",
          label: "上午",
          value: "1",
          modelValue: formData.value.jc
        }),
        k: common_vendor.o(($event) => formData.value.jc = $event),
        l: common_vendor.p({
          name: "jc",
          label: "下午",
          value: "2",
          modelValue: formData.value.jc
        }),
        m: common_vendor.o(($event) => formData.value.jc = $event),
        n: common_vendor.p({
          name: "jc",
          label: "晚上",
          value: "3",
          modelValue: formData.value.jc
        }),
        o: common_vendor.p({
          field: "jc"
        }),
        p: common_vendor.sr(formRef, "3e64f3f1-0", {
          "k": "formRef"
        }),
        q: common_vendor.o(($event) => formData.value = $event),
        r: common_vendor.p({
          rules: fieldConfigs,
          modelValue: formData.value
        })
      } : {
        s: common_vendor.t(displayText.value)
      }, {
        t: attendanceMode.value !== "overview" ? 1 : "",
        v: common_vendor.o(handleModeChange),
        w: common_vendor.o(handleStatusChange),
        x: common_vendor.o(handleStudentClick),
        y: common_vendor.p({
          students: studentList.value,
          layout: seatLayout.value,
          mode: attendanceMode.value
        }),
        z: attendanceMode.value === "overview-simple"
      }, attendanceMode.value === "overview-simple" ? {
        A: showPullIndicator.value ? 1 : ""
      } : {}, {
        B: attendanceMode.value !== "attendance"
      }, attendanceMode.value !== "attendance" ? {
        C: common_vendor.o(handleBottomAction),
        D: common_vendor.p({
          buttons: bottomButtons
        })
      } : {}, {
        E: common_vendor.o(handlePageTouchStart),
        F: common_vendor.o(handlePageTouchMove),
        G: common_vendor.o(handlePageTouchEnd),
        H: common_vendor.gei(_ctx, "")
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3e64f3f1"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/kqjl/kqjl_bzrDm.js.map
