"use strict";
const common_vendor = require("../../common/vendor.js");
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const common_libraries_day = require("../../common/libraries/day.js");
const gen_Apis = require("../../gen/Apis.js");
const WORKORDER_show_log_model = require("./model.js");
const getShow = (id) => {
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkOrders.Show, { id }).then((res) => {
    WORKORDER_show_log_model.useModel.dataShow.value = res == null ? void 0 : res.data;
  });
};
const getHouseWorkLogs = (id) => {
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkLogs.List, { house_work_orders_id: id }).then((res) => {
    WORKORDER_show_log_model.useModel.logsData.value = res == null ? void 0 : res.data;
  });
};
const method = {
  getShow,
  getHouseWorkLogs,
  toPageAddLogs() {
    var _a, _b, _c, _d, _e, _f;
    if (((_c = (_b = (_a = WORKORDER_show_log_model.useModel) == null ? void 0 : _a.dataShow) == null ? void 0 : _b.value) == null ? void 0 : _c.status) === "PendingAcceptance") {
      common_vendor.index.navigateTo({
        url: `/WORKORDER/acceptance/index?id=${(_f = (_e = (_d = WORKORDER_show_log_model.useModel) == null ? void 0 : _d.dataShow) == null ? void 0 : _e.value) == null ? void 0 : _f.id}`
      });
    }
  },
  handleClosed() {
    var _a, _b, _c, _d, _e, _f;
    if (((_c = (_b = (_a = WORKORDER_show_log_model.useModel) == null ? void 0 : _a.dataShow) == null ? void 0 : _b.value) == null ? void 0 : _c.expect_start_time) && common_libraries_day.specificTime((_f = (_e = (_d = WORKORDER_show_log_model.useModel) == null ? void 0 : _d.dataShow) == null ? void 0 : _e.value) == null ? void 0 : _f.expect_start_time)) {
      common_vendor.index.showModal({
        title: "提示",
        content: "距离工单开始时间小于2小时，无法关闭工单！若需取消，请联系处理人员操作。",
        cancelText: "点错了",
        success: function(res) {
          if (res.confirm) {
            console.log("用户点击确定");
          } else if (res.cancel) {
            console.log("用户点击取消");
          }
        }
      });
      return false;
    }
    common_vendor.index.showModal({
      title: "提示",
      content: "关闭工单后无法继续操作，如需继续需要重新提交，您是否确认关闭",
      cancelText: "点错了",
      success: function(res) {
        var _a2, _b2, _c2;
        if (res.confirm) {
          common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkOrders.Close, {
            id: (_c2 = (_b2 = (_a2 = WORKORDER_show_log_model.useModel) == null ? void 0 : _a2.dataShow) == null ? void 0 : _b2.value) == null ? void 0 : _c2.id
          }).then((res2) => {
            var _a3, _b3, _c3, _d2, _e2, _f2;
            getShow((_c3 = (_b3 = (_a3 = WORKORDER_show_log_model.useModel) == null ? void 0 : _a3.dataShow) == null ? void 0 : _b3.value) == null ? void 0 : _c3.id);
            getHouseWorkLogs((_f2 = (_e2 = (_d2 = WORKORDER_show_log_model.useModel) == null ? void 0 : _d2.dataShow) == null ? void 0 : _e2.value) == null ? void 0 : _f2.id);
          });
          console.log("用户点击确定");
        } else if (res.cancel) {
          console.log("用户点击取消");
        }
      }
    });
  },
  handlePendingPaymentQrCode(e) {
  },
  handleCopyPhone(phone) {
    if (phone) {
      common_vendor.index.makePhoneCall({
        phoneNumber: phone
        //仅为示例，并非真实的电话号码
      });
    }
  }
};
exports.method = method;
