"use strict";
const common_vendor = require("../../../common/vendor.js");
const INDEX_task_show_model = require("./model.js");
const common_libraries_apiLoading = require("../../../common/libraries/apiLoading.js");
const gen_Apis = require("../../../gen/Apis.js");
const getAssignPermission = (id) => {
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkOrders.GetAssignPermission, {
    id
  }).then((res) => {
    INDEX_task_show_model.useModel.assignPermissionData.value = res == null ? void 0 : res.data;
  });
};
const method = {
  getShow(id) {
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkOrders.Show, { id }).then((res) => {
      var _a;
      INDEX_task_show_model.useModel.dataShow.value = res == null ? void 0 : res.data;
      getAssignPermission((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.id);
    });
  },
  getHouseWorkLogs(id) {
    common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkLogs.List, { house_work_orders_id: id }).then((res) => {
      INDEX_task_show_model.useModel.logsData.value = res == null ? void 0 : res.data;
    });
  },
  toPageUpdate(type) {
    var _a, _b, _c;
    common_vendor.index.navigateTo({
      url: `/INDEX/task/update/index?id=${(_c = (_b = (_a = INDEX_task_show_model.useModel) == null ? void 0 : _a.dataShow) == null ? void 0 : _b.value) == null ? void 0 : _c.id}&type=${type}`
    });
  },
  handlePreviewImage(idx) {
    var _a, _b, _c, _d;
    let urlList = ((_d = (_c = (_b = (_a = INDEX_task_show_model.useModel) == null ? void 0 : _a.dataShow) == null ? void 0 : _b.value) == null ? void 0 : _c.attachments) == null ? void 0 : _d.map((item) => item == null ? void 0 : item.url)) || [];
    common_vendor.index.previewImage({
      urls: urlList,
      current: idx
    });
  },
  handlePendingPaymentQrCode(e) {
  },
  handleCopyPhone() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
    if ((_c = (_b = (_a = INDEX_task_show_model.useModel) == null ? void 0 : _a.dataShow) == null ? void 0 : _b.value) == null ? void 0 : _c.contact_phone) {
      common_vendor.index.makePhoneCall({
        phoneNumber: (_f = (_e = (_d = INDEX_task_show_model.useModel) == null ? void 0 : _d.dataShow) == null ? void 0 : _e.value) == null ? void 0 : _f.contact_phone
      });
      return;
    }
    if ((_i = (_h = (_g = INDEX_task_show_model.useModel) == null ? void 0 : _g.dataShow) == null ? void 0 : _h.value) == null ? void 0 : _i.reporter_phone) {
      common_vendor.index.makePhoneCall({
        phoneNumber: (_l = (_k = (_j = INDEX_task_show_model.useModel) == null ? void 0 : _j.dataShow) == null ? void 0 : _k.value) == null ? void 0 : _l.reporter_phone
      });
      return;
    }
    common_vendor.index.showToast({
      title: "暂无电话号码",
      icon: "none"
    });
  }
};
exports.method = method;
