"use strict";
const common_vendor = require("../../common/vendor.js");
const common_libraries_apiLoading = require("../../common/libraries/apiLoading.js");
const gen_Apis = require("../../gen/Apis.js");
const WORKORDER_list_model = require("./model.js");
const getList = () => {
  var _a, _b;
  common_libraries_apiLoading.getApiLoading(gen_Apis.Apis.WorkOrder.HouseWorkOrders.List, (_b = (_a = WORKORDER_list_model.useModel) == null ? void 0 : _a.formData) == null ? void 0 : _b.value).then((res) => {
    WORKORDER_list_model.useModel.listData.value = [...WORKORDER_list_model.useModel.listData.value, ...res == null ? void 0 : res.data];
    WORKORDER_list_model.useModel.metaData.value = res == null ? void 0 : res.meta;
  });
};
const handleSearch = () => {
  WORKORDER_list_model.useModel.formData.value.page = 1;
  WORKORDER_list_model.useModel.listData.value = [];
  getList();
};
const method = {
  getList,
  handleChangeTabs(idx, e) {
    WORKORDER_list_model.useModel.currentTabs.value = idx;
    WORKORDER_list_model.useModel.formData.value.status = e == null ? void 0 : e.value;
    handleSearch();
  },
  handleLoad(page) {
    WORKORDER_list_model.useModel.formData.value.page = page;
    getList();
  },
  handleCopyPhone(e) {
    if (e == null ? void 0 : e.contact_phone) {
      common_vendor.index.makePhoneCall({
        phoneNumber: e == null ? void 0 : e.contact_phone
      });
      return;
    }
    if (e == null ? void 0 : e.reporter_phone) {
      common_vendor.index.makePhoneCall({
        phoneNumber: e == null ? void 0 : e.reporter_phone
      });
      return;
    }
    common_vendor.index.showToast({
      title: "暂无电话号码",
      icon: "none"
    });
  },
  handleUpdateSetp(e) {
    if ((e == null ? void 0 : e.type) === "SecurityInspection") {
      common_vendor.index.navigateTo({
        url: `/WORKORDER/show_patrol_task_locations/index?id=${e == null ? void 0 : e.id}`
      });
      return;
    }
    if ((e == null ? void 0 : e.type) === "RenovationInspection" || (e == null ? void 0 : e.type) === "RenovationAcceptance") {
      common_vendor.index.navigateTo({
        url: `/WORKORDER/patrol_update/index?id=${e == null ? void 0 : e.id}&type=${e == null ? void 0 : e.type}`
      });
      return;
    }
    common_vendor.index.navigateTo({
      url: `/WORKORDER/update/index?id=${e == null ? void 0 : e.id}&projects_id=${e == null ? void 0 : e.asset_projects_id}&location=${e == null ? void 0 : e.location}`
    });
  },
  handleToDetail(e) {
    common_vendor.index.navigateTo({
      url: `/WORKORDER/show/index?id=${e == null ? void 0 : e.id}`
    });
  },
  handlePendingPaymentQrCode(e) {
    var _a;
    common_vendor.index.navigateTo({
      url: `/WORKORDER/poster/index?id=${e == null ? void 0 : e.id}&full_name=${(_a = e == null ? void 0 : e.asset_house) == null ? void 0 : _a.full_name}&amount=${e == null ? void 0 : e.amount}`
    });
  }
};
exports.method = method;
