// module/health/components/field-ruler/field-ruler.ts
import { getOfflineTreatmentListMethod } from "../../request";
Component({
  behaviors: ["wx://form-field-group"],
  lifetimes: {
    attached() {
      this.getOfflineTreatmentList();
    },
  },
  methods: {
    onRecord(e: any) {
      const id = e.currentTarget.dataset.id;
      if (id) {
        // 跳转核销记录
        wx.navigateTo({
          url: `/module/care/pages/care/verifyRecord?id=${id}`,
          success: () => {},
          fail: (error) => {
            console.error("跳转失败:", error);
          },
        });
      } else {
        wx.showToast({
          title: "暂无核销记录",
          icon: "none",
        });
      }
    },
    // 更多记录
    onMore() {
      wx.navigateTo({
        url: "/module/care/pages/offlineTreatment/offlineTreatment",
      });
    },
    async getOfflineTreatmentList() {
      // 0 进行中 1 已完成
      const res = await getOfflineTreatmentListMethod("0");
      if (res && res.data && res.data.length > 0) {
        this.setData({
          offlineTreatmentList: res.data,
        });
      } else {
        this.setData({
          offlineTreatmentList: [],
        });
      }
    },
  },
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    loading: false,
    offlineTreatmentList: [],
  },
  observers: {},
});
